From 67db8f03c5c9e81e11b5f3276b50ee23e09a2659 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 17 Sep 2001 11:48:29 +0000 Subject: [PATCH] move to SAFE_FREE() --- source/utils/make_printerdef.c | 16 ++++++++-------- source/utils/nmblookup.c | 2 +- source/utils/smbcacls.c | 22 ++++++++++------------ source/utils/smbpasswd.c | 12 ++++++------ source/utils/smbtree.c | 2 +- source/web/cgi.c | 2 +- source/web/diagnose.c | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) diff --git a/source/utils/make_printerdef.c b/source/utils/make_printerdef.c index bfbf6fa4995..47589984ccb 100644 --- a/source/utils/make_printerdef.c +++ b/source/utils/make_printerdef.c @@ -154,8 +154,8 @@ static void lookup_strings(FILE *fichier) temp2=(char *)malloc(sizeof(pstring)); if(temp == NULL || temp2 == NULL) { - safe_free(temp); - safe_free(temp2); + SAFE_FREE(temp); + SAFE_FREE(temp2); fprintf(stderr,"lookup_strings: malloc fail !\n"); exit(1); } @@ -218,8 +218,8 @@ static void lookup_entry(FILE *fichier,char *chaine) temp2=(char *)malloc(sizeof(pstring)); if(temp == NULL || temp2 == NULL) { - safe_free(temp); - safe_free(temp2); + SAFE_FREE(temp); + SAFE_FREE(temp2); fprintf(stderr,"lookup_entry: malloc fail !\n"); exit(1); } @@ -276,9 +276,9 @@ static char *find_desc(FILE *fichier,char *text) long_desc=(char *)malloc(sizeof(pstring)); short_desc=(char *)malloc(sizeof(pstring)); if (!chaine || !long_desc || !short_desc) { - safe_free(chaine); - safe_free(long_desc); - safe_free(short_desc); + SAFE_FREE(chaine); + SAFE_FREE(long_desc); + SAFE_FREE(short_desc); fprintf(stderr,"find_desc: Unable to malloc memory\n"); exit(1); } @@ -307,7 +307,7 @@ static char *find_desc(FILE *fichier,char *text) if (!strcmp(text,long_desc)) found=1; } - free(chaine); + SAFE_FREE(chaine); if (!found || !crap) return(NULL); while(*crap==' ') crap++; pstrcpy(short_desc,crap); diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c index 2d86cc0a35c..ff675a72e50 100644 --- a/source/utils/nmblookup.c +++ b/source/utils/nmblookup.c @@ -124,7 +124,7 @@ static void do_node_status(int fd, char *name, int type, struct in_addr ip) cleanname,status[i].type, node_status_flags(status[i].flags)); } - free(status); + SAFE_FREE(status); } d_printf("\n"); } diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c index 914e99367bb..ba5630a9d86 100644 --- a/source/utils/smbcacls.c +++ b/source/utils/smbcacls.c @@ -328,7 +328,7 @@ static BOOL add_ace(SEC_ACL **the_acl, SEC_ACE *ace) memcpy(aces, (*the_acl)->ace, (*the_acl)->num_aces * sizeof(SEC_ACE)); memcpy(aces+(*the_acl)->num_aces, ace, sizeof(SEC_ACE)); new = make_sec_acl(ctx,(*the_acl)->revision,1+(*the_acl)->num_aces, aces); - free(aces); + SAFE_FREE(aces); (*the_acl) = new; return True; } @@ -391,8 +391,8 @@ static SEC_DESC *sec_desc_parse(char *str) ret = make_sec_desc(ctx,revision, owner_sid, grp_sid, NULL, dacl, &sd_size); - if (grp_sid) free(grp_sid); - if (owner_sid) free(owner_sid); + SAFE_FREE(grp_sid); + SAFE_FREE(owner_sid); return ret; } @@ -605,10 +605,8 @@ static int cacl_set(struct cli_state *cli, char *filename, } old->dacl->num_aces--; if (old->dacl->num_aces == 0) { - free(old->dacl->ace); - old->dacl->ace=NULL; - free(old->dacl); - old->dacl = NULL; + SAFE_FREE(old->dacl->ace); + SAFE_FREE(old->dacl); old->off_dacl = 0; } found = True; @@ -713,14 +711,14 @@ struct cli_state *connect_one(char *share) if (!(c=cli_initialise(NULL)) || !cli_connect(c, server, &ip)) { DEBUG(0,("Connection to %s failed\n", server)); cli_shutdown(c); - safe_free(c); + SAFE_FREE(c); return NULL; } if (!cli_session_request(c, &calling, &called)) { DEBUG(0,("session request to %s failed\n", called.name)); cli_shutdown(c); - safe_free(c); + SAFE_FREE(c); if (strcmp(called.name, "*SMBSERVER")) { make_nmb_name(&called , "*SMBSERVER", 0x20); goto again; @@ -733,7 +731,7 @@ struct cli_state *connect_one(char *share) if (!cli_negprot(c)) { DEBUG(0,("protocol negotiation failed\n")); cli_shutdown(c); - safe_free(c); + SAFE_FREE(c); return NULL; } @@ -750,7 +748,7 @@ struct cli_state *connect_one(char *share) lp_workgroup())) { DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); cli_shutdown(c); - safe_free(c); + SAFE_FREE(c); return NULL; } @@ -760,7 +758,7 @@ struct cli_state *connect_one(char *share) password, strlen(password)+1)) { DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); cli_shutdown(c); - safe_free(c); + SAFE_FREE(c); return NULL; } diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c index da5f817c802..14b10c17000 100644 --- a/source/utils/smbpasswd.c +++ b/source/utils/smbpasswd.c @@ -491,14 +491,14 @@ static char *prompt_for_new_password(BOOL stdin_get) p = get_pass("New SMB password:", stdin_get); fstrcpy(new_passwd, p); - safe_free(p); + SAFE_FREE(p); p = get_pass("Retype new SMB password:", stdin_get); if (strcmp(p, new_passwd)) { fprintf(stderr, "Mismatch - password unchanged.\n"); ZERO_ARRAY(new_passwd); - safe_free(p); + SAFE_FREE(p); return NULL; } @@ -730,7 +730,7 @@ static int process_root(int argc, char *argv[]) } if (local_flags & LOCAL_ADD_USER) { - safe_free(new_passwd); + SAFE_FREE(new_passwd); new_passwd = xstrdup(user_name); strlower(new_passwd); } @@ -803,7 +803,7 @@ static int process_root(int argc, char *argv[]) } done: - safe_free(new_passwd); + SAFE_FREE(new_passwd); return result; } @@ -898,8 +898,8 @@ static int process_nonroot(int argc, char *argv[]) printf("Password changed for user %s\n", user_name); done: - safe_free(old_passwd); - safe_free(new_passwd); + SAFE_FREE(old_passwd); + SAFE_FREE(new_passwd); return result; } diff --git a/source/utils/smbtree.c b/source/utils/smbtree.c index 191a9124f77..d7842d1e029 100644 --- a/source/utils/smbtree.c +++ b/source/utils/smbtree.c @@ -161,7 +161,7 @@ static struct cli_state *get_ipc_connect(char *server, if (cli && cli->initialised) cli_shutdown(cli); - free(cli); + SAFE_FREE(cli); return NULL; } diff --git a/source/web/cgi.c b/source/web/cgi.c index 88f4d3f36fa..35473790840 100644 --- a/source/web/cgi.c +++ b/source/web/cgi.c @@ -168,7 +168,7 @@ void cgi_load_variables(FILE *f1) variables[num_variables].name = strdup(line); variables[num_variables].value = strdup(p+1); - free(line); + SAFE_FREE(line); if (!variables[num_variables].name || !variables[num_variables].value) diff --git a/source/web/diagnose.c b/source/web/diagnose.c index f22fe0d9b25..bf2e6da17d1 100644 --- a/source/web/diagnose.c +++ b/source/web/diagnose.c @@ -36,7 +36,7 @@ BOOL nmbd_running(void) if ((ip_list = name_query(fd, "__SAMBA__", 0, True, True, loopback_ip, &count)) != NULL) { - free(ip_list); + SAFE_FREE(ip_list); close(fd); return True; } -- 2.11.4.GIT