aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Lehmann <aaronl@vitelius.com>2002-11-28 11:27:31 +0000
committerAaron Lehmann <aaronl@vitelius.com>2002-11-28 11:27:31 +0000
commita170e1c858d35c474ceb9fecb41b37d681424094 (patch)
treecda2b13f10ca1ab0a3559d4b6ff663ed20d7106c
parent1652855fbc830f41c7ee56ece1a30b328c4fb395 (diff)
downloadbusybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.tar.gz
busybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.tar.bz2
busybox-w32-a170e1c858d35c474ceb9fecb41b37d681424094.zip
Change if(x)free(x); to free(x);
-rw-r--r--archival/dpkg.c28
-rw-r--r--archival/gzip.c2
-rw-r--r--coreutils/ls.c3
-rw-r--r--editors/awk.c9
-rw-r--r--editors/sed.c3
-rw-r--r--editors/vi.c39
-rw-r--r--findutils/grep.c6
-rw-r--r--libpwdgrp/__getgrent.c3
-rw-r--r--modutils/insmod.c7
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/udhcp/files.c2
-rw-r--r--shell/hush.c5
-rw-r--r--shell/lash.c12
-rw-r--r--util-linux/fsck_minix.c4
-rw-r--r--util-linux/getopt.c9
-rw-r--r--util-linux/umount.c6
16 files changed, 47 insertions, 95 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 8b25bace3..23509fcb5 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -491,13 +491,9 @@ void free_package(common_node_t *node)
491 unsigned short i; 491 unsigned short i;
492 if (node) { 492 if (node) {
493 for (i = 0; i < node->num_of_edges; i++) { 493 for (i = 0; i < node->num_of_edges; i++) {
494 if (node->edge[i]) { 494 free(node->edge[i]);
495 free(node->edge[i]);
496 }
497 }
498 if (node->edge) {
499 free(node->edge);
500 } 495 }
496 free(node->edge);
501 free(node); 497 free(node);
502 } 498 }
503} 499}
@@ -571,12 +567,8 @@ unsigned int fill_package_struct(char *control_buffer)
571 break; 567 break;
572 } 568 }
573fill_package_struct_cleanup: 569fill_package_struct_cleanup:
574 if (field_name) { 570 free(field_name);
575 free(field_name); 571 free(field_value);
576 }
577 if (field_value) {
578 free(field_value);
579 }
580 } 572 }
581 573
582 if (new_node->version == search_name_hashtable("unknown")) { 574 if (new_node->version == search_name_hashtable("unknown")) {
@@ -880,9 +872,7 @@ void write_status_file(deb_file_t **deb_file)
880 fprintf(new_status_file, "%s\n\n", control_buffer); 872 fprintf(new_status_file, "%s\n\n", control_buffer);
881 } 873 }
882 874
883 if (status_from_file != NULL) { 875 free(status_from_file);
884 free(status_from_file);
885 }
886 free(package_name); 876 free(package_name);
887 free(control_buffer); 877 free(control_buffer);
888 } 878 }
@@ -1661,9 +1651,7 @@ int dpkg_main(int argc, char **argv)
1661 free(deb_file); 1651 free(deb_file);
1662 1652
1663 for (i = 0; i < NAME_HASH_PRIME; i++) { 1653 for (i = 0; i < NAME_HASH_PRIME; i++) {
1664 if (name_hashtable[i] != NULL) { 1654 free(name_hashtable[i]);
1665 free(name_hashtable[i]);
1666 }
1667 } 1655 }
1668 1656
1669 for (i = 0; i < PACKAGE_HASH_PRIME; i++) { 1657 for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
@@ -1673,9 +1661,7 @@ int dpkg_main(int argc, char **argv)
1673 } 1661 }
1674 1662
1675 for (i = 0; i < STATUS_HASH_PRIME; i++) { 1663 for (i = 0; i < STATUS_HASH_PRIME; i++) {
1676 if (status_hashtable[i] != NULL) { 1664 free(status_hashtable[i]);
1677 free(status_hashtable[i]);
1678 }
1679 } 1665 }
1680 1666
1681 return(EXIT_SUCCESS); 1667 return(EXIT_SUCCESS);
diff --git a/archival/gzip.c b/archival/gzip.c
index da931579f..971724d74 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -111,7 +111,7 @@ typedef unsigned long ulg;
111# define ALLOC(type, array, size) { \ 111# define ALLOC(type, array, size) { \
112 array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ 112 array = (type*)xcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
113 } 113 }
114# define FREE(array) {if (array != NULL) free(array), array=NULL;} 114# define FREE(array) {free(array), array=NULL;}
115#else 115#else
116# define DECLARE(type, array, size) static type array[size] 116# define DECLARE(type, array, size) static type array[size]
117# define ALLOC(type, array, size) 117# define ALLOC(type, array, size)
diff --git a/coreutils/ls.c b/coreutils/ls.c
index d2a935d82..853a18059 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -360,8 +360,7 @@ static void dfree(struct dnode **dnp)
360 360
361 cur = dnp[0]; 361 cur = dnp[0];
362 while (cur != NULL) { 362 while (cur != NULL) {
363 if (cur->fullname != NULL) 363 free(cur->fullname); /* free the filename */
364 free(cur->fullname); /* free the filename */
365 next = cur->next; 364 next = cur->next;
366 free(cur); /* free the dnode */ 365 free(cur); /* free the dnode */
367 cur = next; 366 cur = next;
diff --git a/editors/awk.c b/editors/awk.c
index aea852b0d..44c2f45b2 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -650,7 +650,7 @@ static void clear_array(xhash *array) {
650 while (hi) { 650 while (hi) {
651 thi = hi; 651 thi = hi;
652 hi = hi->next; 652 hi = hi->next;
653 if (thi->data.v.string) free(thi->data.v.string); 653 free(thi->data.v.string);
654 free(thi); 654 free(thi);
655 } 655 }
656 array->items[i] = NULL; 656 array->items[i] = NULL;
@@ -661,7 +661,7 @@ static void clear_array(xhash *array) {
661/* clear a variable */ 661/* clear a variable */
662static var *clrvar(var *v) { 662static var *clrvar(var *v) {
663 663
664 if (v->string && !(v->type & VF_FSTR)) 664 if (!(v->type & VF_FSTR))
665 free(v->string); 665 free(v->string);
666 666
667 v->type &= VF_DONTTOUCH; 667 v->type &= VF_DONTTOUCH;
@@ -1504,7 +1504,7 @@ static void split_f0(void) {
1504 return; 1504 return;
1505 1505
1506 is_f0_split = TRUE; 1506 is_f0_split = TRUE;
1507 if (fstrings) free(fstrings); 1507 free(fstrings);
1508 fsrealloc(0); 1508 fsrealloc(0);
1509 n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings); 1509 n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings);
1510 fsrealloc(n); 1510 fsrealloc(n);
@@ -2376,8 +2376,7 @@ re_cont:
2376 X.rsm = (rstream *)hash_search(fdhash, L.s); 2376 X.rsm = (rstream *)hash_search(fdhash, L.s);
2377 if (X.rsm) { 2377 if (X.rsm) {
2378 R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F); 2378 R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F);
2379 if (X.rsm->buffer) 2379 free(X.rsm->buffer);
2380 free(X.rsm->buffer);
2381 hash_remove(fdhash, L.s); 2380 hash_remove(fdhash, L.s);
2382 } 2381 }
2383 if (R.i != 0) 2382 if (R.i != 0)
diff --git a/editors/sed.c b/editors/sed.c
index 23e9d545b..df623465f 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -130,8 +130,7 @@ static void destroy_cmd_strs(void)
130 regfree(sed_cmds[ncmds].sub_match); 130 regfree(sed_cmds[ncmds].sub_match);
131 free(sed_cmds[ncmds].sub_match); 131 free(sed_cmds[ncmds].sub_match);
132 } 132 }
133 if (sed_cmds[ncmds].replace) 133 free(sed_cmds[ncmds].replace);
134 free(sed_cmds[ncmds].replace);
135 } 134 }
136 135
137 /* destroy the array */ 136 /* destroy the array */
diff --git a/editors/vi.c b/editors/vi.c
index 1275d133b..835adb62e 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21static const char vi_Version[] = 21static const char vi_Version[] =
22 "$Id: vi.c,v 1.24 2002/10/26 10:19:19 andersen Exp $"; 22 "$Id: vi.c,v 1.25 2002/11/28 11:27:23 aaronl Exp $";
23 23
24/* 24/*
25 * To compile for standalone use: 25 * To compile for standalone use:
@@ -383,8 +383,7 @@ extern int vi_main(int argc, char **argv)
383 } else { 383 } else {
384 for (; optind < argc; optind++) { 384 for (; optind < argc; optind++) {
385 editing = 1; // 0=exit, 1=one file, 2+ =many files 385 editing = 1; // 0=exit, 1=one file, 2+ =many files
386 if (cfn != 0) 386 free(cfn);
387 free(cfn);
388 cfn = (Byte *) xstrdup(argv[optind]); 387 cfn = (Byte *) xstrdup(argv[optind]);
389 edit_file(cfn); 388 edit_file(cfn);
390 } 389 }
@@ -490,10 +489,8 @@ static void edit_file(Byte * fn)
490 offset = 0; // no horizontal offset 489 offset = 0; // no horizontal offset
491 c = '\0'; 490 c = '\0';
492#ifdef CONFIG_FEATURE_VI_DOT_CMD 491#ifdef CONFIG_FEATURE_VI_DOT_CMD
493 if (last_modifying_cmd != 0) 492 free(last_modifying_cmd);
494 free(last_modifying_cmd); 493 free(ioq_start);
495 if (ioq_start != NULL)
496 free(ioq_start);
497 ioq = ioq_start = last_modifying_cmd = 0; 494 ioq = ioq_start = last_modifying_cmd = 0;
498 adding2q = 0; 495 adding2q = 0;
499#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 496#endif /* CONFIG_FEATURE_VI_DOT_CMD */
@@ -998,8 +995,7 @@ static void colon(Byte * buf)
998 // There is a read-able regular file 995 // There is a read-able regular file
999 // make this the current file 996 // make this the current file
1000 q = (Byte *) xstrdup((char *) fn); // save the cfn 997 q = (Byte *) xstrdup((char *) fn); // save the cfn
1001 if (cfn != 0) 998 free(cfn); // free the old name
1002 free(cfn); // free the old name
1003 cfn = q; // remember new cfn 999 cfn = q; // remember new cfn
1004 1000
1005 vc5: 1001 vc5:
@@ -1048,8 +1044,7 @@ static void colon(Byte * buf)
1048 } 1044 }
1049 if (strlen((char *) args) > 0) { 1045 if (strlen((char *) args) > 0) {
1050 // user wants a new filename 1046 // user wants a new filename
1051 if (cfn != NULL) 1047 free(cfn);
1052 free(cfn);
1053 cfn = (Byte *) xstrdup((char *) args); 1048 cfn = (Byte *) xstrdup((char *) args);
1054 } else { 1049 } else {
1055 // user wants file status info 1050 // user wants file status info
@@ -1635,8 +1630,7 @@ static Byte *new_screen(int ro, int co)
1635{ 1630{
1636 int li; 1631 int li;
1637 1632
1638 if (screen != 0) 1633 free(screen);
1639 free(screen);
1640 screensize = ro * co + 8; 1634 screensize = ro * co + 8;
1641 screen = (Byte *) xmalloc(screensize); 1635 screen = (Byte *) xmalloc(screensize);
1642 // initialize the new screen. assume this will be a empty file. 1636 // initialize the new screen. assume this will be a empty file.
@@ -1652,10 +1646,7 @@ static Byte *new_text(int size)
1652{ 1646{
1653 if (size < 10240) 1647 if (size < 10240)
1654 size = 10240; // have a minimum size for new files 1648 size = 10240; // have a minimum size for new files
1655 if (text != 0) { 1649 free(text);
1656 //text -= 4;
1657 free(text);
1658 }
1659 text = (Byte *) xmalloc(size + 8); 1650 text = (Byte *) xmalloc(size + 8);
1660 memset(text, '\0', size); // clear new text[] 1651 memset(text, '\0', size); // clear new text[]
1661 //text += 4; // leave some room for "oops" 1652 //text += 4; // leave some room for "oops"
@@ -2171,8 +2162,7 @@ extern inline void print_literal(Byte * buf, Byte * s) // copy s to buf, convert
2171static void start_new_cmd_q(Byte c) 2162static void start_new_cmd_q(Byte c)
2172{ 2163{
2173 // release old cmd 2164 // release old cmd
2174 if (last_modifying_cmd != 0) 2165 free(last_modifying_cmd);
2175 free(last_modifying_cmd);
2176 // get buffer for new cmd 2166 // get buffer for new cmd
2177 last_modifying_cmd = (Byte *) xmalloc(BUFSIZ); 2167 last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
2178 memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue 2168 memset(last_modifying_cmd, '\0', BUFSIZ); // clear new cmd queue
@@ -2227,9 +2217,7 @@ static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a registe
2227 } 2217 }
2228 cnt = q - p + 1; 2218 cnt = q - p + 1;
2229 t = reg[dest]; 2219 t = reg[dest];
2230 if (t != 0) { // if already a yank register 2220 free(t); // if already a yank register, free it
2231 free(t); // free it
2232 }
2233 t = (Byte *) xmalloc(cnt + 1); // get a new register 2221 t = (Byte *) xmalloc(cnt + 1); // get a new register
2234 memset(t, '\0', cnt + 1); // clear new text[] 2222 memset(t, '\0', cnt + 1); // clear new text[]
2235 strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer 2223 strncpy((char *) t, (char *) p, cnt); // copy text[] into bufer
@@ -2615,8 +2603,7 @@ static Byte *get_input_line(Byte * prompt) // get input line- use "status line"
2615 } 2603 }
2616 } 2604 }
2617 refresh(FALSE); 2605 refresh(FALSE);
2618 if (obufp != NULL) 2606 free(obufp);
2619 free(obufp);
2620 obufp = (Byte *) xstrdup((char *) buf); 2607 obufp = (Byte *) xstrdup((char *) buf);
2621 return (obufp); 2608 return (obufp);
2622} 2609}
@@ -3454,9 +3441,7 @@ key_cmd_mode:
3454 goto dc3; // if no pat re-use old pat 3441 goto dc3; // if no pat re-use old pat
3455 if (strlen((char *) q) > 1) { // new pat- save it and find 3442 if (strlen((char *) q) > 1) { // new pat- save it and find
3456 // there is a new pat 3443 // there is a new pat
3457 if (last_search_pattern != 0) { 3444 free(last_search_pattern);
3458 free(last_search_pattern);
3459 }
3460 last_search_pattern = (Byte *) xstrdup((char *) q); 3445 last_search_pattern = (Byte *) xstrdup((char *) q);
3461 goto dc3; // now find the pattern 3446 goto dc3; // now find the pattern
3462 } 3447 }
diff --git a/findutils/grep.c b/findutils/grep.c
index 6fe183325..cc2b697e8 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -153,8 +153,7 @@ static void grep_file(FILE *file)
153 else { /* no match */ 153 else { /* no match */
154 /* Add the line to the circular 'before' buffer */ 154 /* Add the line to the circular 'before' buffer */
155 if(lines_before) { 155 if(lines_before) {
156 if(before_buf[curpos]) 156 free(before_buf[curpos]);
157 free(before_buf[curpos]);
158 before_buf[curpos] = xstrdup(line); 157 before_buf[curpos] = xstrdup(line);
159 curpos = (curpos + 1) % lines_before; 158 curpos = (curpos + 1) % lines_before;
160 } 159 }
@@ -225,8 +224,7 @@ static void destroy_regexes(void)
225 while (--nregexes >= 0) { 224 while (--nregexes >= 0) {
226 regfree(&(regexes[nregexes])); 225 regfree(&(regexes[nregexes]));
227 } 226 }
228 if (regexes) 227 free(regexes);
229 free(regexes);
230} 228}
231#endif 229#endif
232 230
diff --git a/libpwdgrp/__getgrent.c b/libpwdgrp/__getgrent.c
index 39cf1890a..5fb4193cb 100644
--- a/libpwdgrp/__getgrent.c
+++ b/libpwdgrp/__getgrent.c
@@ -186,8 +186,7 @@ struct group *__getgrent(int grp_fd)
186 members[member_num + 1] = NULL; 186 members[member_num + 1] = NULL;
187 } 187 }
188#else /* !GR_SCALE_DYNAMIC */ 188#else /* !GR_SCALE_DYNAMIC */
189 if (members != NULL) 189 free(members);
190 free(members);
191 members = (char **) malloc((member_num + 1) * sizeof(char *)); 190 members = (char **) malloc((member_num + 1) * sizeof(char *));
192 for ( ; field_begin && *field_begin != '\0'; field_begin = ptr) { 191 for ( ; field_begin && *field_begin != '\0'; field_begin = ptr) {
193 if ((ptr = strchr(field_begin, ',')) != NULL) 192 if ((ptr = strchr(field_begin, ',')) != NULL)
diff --git a/modutils/insmod.c b/modutils/insmod.c
index b367e84af..eda4e1a48 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -234,7 +234,7 @@
234#ifndef MODUTILS_MODULE_H 234#ifndef MODUTILS_MODULE_H
235static const int MODUTILS_MODULE_H = 1; 235static const int MODUTILS_MODULE_H = 1;
236 236
237#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $" 237#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
238 238
239/* This file contains the structures used by the 2.0 and 2.1 kernels. 239/* This file contains the structures used by the 2.0 and 2.1 kernels.
240 We do not use the kernel headers directly because we do not wish 240 We do not use the kernel headers directly because we do not wish
@@ -455,7 +455,7 @@ int delete_module(const char *);
455#ifndef MODUTILS_OBJ_H 455#ifndef MODUTILS_OBJ_H
456static const int MODUTILS_OBJ_H = 1; 456static const int MODUTILS_OBJ_H = 1;
457 457
458#ident "$Id: insmod.c,v 1.91 2002/10/10 04:20:21 andersen Exp $" 458#ident "$Id: insmod.c,v 1.92 2002/11/28 11:27:27 aaronl Exp $"
459 459
460/* The relocatable object is manipulated using elfin types. */ 460/* The relocatable object is manipulated using elfin types. */
461 461
@@ -3589,8 +3589,7 @@ extern int insmod_main( int argc, char **argv)
3589 flag_export = 0; 3589 flag_export = 0;
3590 break; 3590 break;
3591 case 'o': /* name the output module */ 3591 case 'o': /* name the output module */
3592 if(m_name) /* Hmmm, duplicate "-o name". */ 3592 free(m_name);
3593 free(m_name);
3594 m_name = xstrdup(optarg); 3593 m_name = xstrdup(optarg);
3595 break; 3594 break;
3596 case 'L': /* Stub warning */ 3595 case 'L': /* Stub warning */
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 295486c98..b50b1ed03 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
246 switch (c) { 246 switch (c) {
247 case 'c': 247 case 'c':
248 len = strlen(optarg) > 255 ? 255 : strlen(optarg); 248 len = strlen(optarg) > 255 ? 255 : strlen(optarg);
249 if (client_config.clientid) free(client_config.clientid); 249 free(client_config.clientid);
250 client_config.clientid = xmalloc(len + 2); 250 client_config.clientid = xmalloc(len + 2);
251 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; 251 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
252 client_config.clientid[OPT_LEN] = len; 252 client_config.clientid[OPT_LEN] = len;
@@ -262,7 +262,7 @@ int main(int argc, char *argv[])
262 case 'h': 262 case 'h':
263 case 'H': 263 case 'H':
264 len = strlen(optarg) > 255 ? 255 : strlen(optarg); 264 len = strlen(optarg) > 255 ? 255 : strlen(optarg);
265 if (client_config.hostname) free(client_config.hostname); 265 free(client_config.hostname);
266 client_config.hostname = xmalloc(len + 2); 266 client_config.hostname = xmalloc(len + 2);
267 client_config.hostname[OPT_CODE] = DHCP_HOST_NAME; 267 client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
268 client_config.hostname[OPT_LEN] = len; 268 client_config.hostname[OPT_LEN] = len;
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 842e0f2db..cf72de1a8 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -38,7 +38,7 @@ static int read_str(char *line, void *arg)
38{ 38{
39 char **dest = arg; 39 char **dest = arg;
40 40
41 if (*dest) free(*dest); 41 free(*dest);
42 *dest = strdup(line); 42 *dest = strdup(line);
43 43
44 return 1; 44 return 1;
diff --git a/shell/hush.c b/shell/hush.c
index 08b3b295f..48d1d1458 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -810,7 +810,7 @@ static void b_reset(o_string *o)
810static void b_free(o_string *o) 810static void b_free(o_string *o)
811{ 811{
812 b_reset(o); 812 b_reset(o);
813 if (o->data != NULL) free(o->data); 813 free(o->data);
814 o->data = NULL; 814 o->data = NULL;
815 o->maxlen = 0; 815 o->maxlen = 0;
816} 816}
@@ -880,8 +880,7 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str)
880#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT 880#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
881 /* Set up the prompt */ 881 /* Set up the prompt */
882 if (promptmode == 1) { 882 if (promptmode == 1) {
883 if (PS1) 883 free(PS1);
884 free(PS1);
885 PS1=xmalloc(strlen(cwd)+4); 884 PS1=xmalloc(strlen(cwd)+4);
886 sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# "); 885 sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# ");
887 *prompt_str = PS1; 886 *prompt_str = PS1;
diff --git a/shell/lash.c b/shell/lash.c
index 7994d2620..c4d6ef04e 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -518,12 +518,9 @@ static void free_job(struct job *cmd)
518 if (cmd->progs[i].redirects) 518 if (cmd->progs[i].redirects)
519 free(cmd->progs[i].redirects); 519 free(cmd->progs[i].redirects);
520 } 520 }
521 if (cmd->progs) 521 free(cmd->progs);
522 free(cmd->progs); 522 free(cmd->text);
523 if (cmd->text) 523 free(cmd->cmdbuf);
524 free(cmd->text);
525 if (cmd->cmdbuf)
526 free(cmd->cmdbuf);
527 keep = cmd->job_list; 524 keep = cmd->job_list;
528 memset(cmd, 0, sizeof(struct job)); 525 memset(cmd, 0, sizeof(struct job));
529 cmd->job_list = keep; 526 cmd->job_list = keep;
@@ -677,8 +674,7 @@ static inline void setup_prompt_string(char **prompt_str)
677#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT 674#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
678 /* Set up the prompt */ 675 /* Set up the prompt */
679 if (shell_context == 0) { 676 if (shell_context == 0) {
680 if (PS1) 677 free(PS1);
681 free(PS1);
682 PS1=xmalloc(strlen(cwd)+4); 678 PS1=xmalloc(strlen(cwd)+4);
683 sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# "); 679 sprintf(PS1, "%s %s", cwd, ( geteuid() != 0 ) ? "$ ":"# ");
684 *prompt_str = PS1; 680 *prompt_str = PS1;
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index dbe4f74b3..d332b6b0a 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -1314,9 +1314,7 @@ static void free_name_list(void)
1314 1314
1315 if (name_list) { 1315 if (name_list) {
1316 for (i = 0; i < MAX_DEPTH; i++) { 1316 for (i = 0; i < MAX_DEPTH; i++) {
1317 if (name_list[i]) { 1317 free(name_list[i]);
1318 free(name_list[i]);
1319 }
1320 } 1318 }
1321 free(name_list); 1319 free(name_list);
1322 } 1320 }
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 2390f3056..e126d7b6e 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -92,8 +92,7 @@ const char *normalize(const char *arg)
92 const char *argptr=arg; 92 const char *argptr=arg;
93 char *bufptr; 93 char *bufptr;
94 94
95 if (BUFFER != NULL) 95 free(BUFFER);
96 free(BUFFER);
97 96
98 if (!quote) { /* Just copy arg */ 97 if (!quote) { /* Just copy arg */
99 BUFFER=xstrdup(arg); 98 BUFFER=xstrdup(arg);
@@ -340,16 +339,14 @@ int getopt_main(int argc, char *argv[])
340 alternative=1; 339 alternative=1;
341 break; 340 break;
342 case 'o': 341 case 'o':
343 if (optstr) 342 free(optstr);
344 free(optstr);
345 optstr=xstrdup(optarg); 343 optstr=xstrdup(optarg);
346 break; 344 break;
347 case 'l': 345 case 'l':
348 add_long_options(optarg); 346 add_long_options(optarg);
349 break; 347 break;
350 case 'n': 348 case 'n':
351 if (name) 349 free(name);
352 free(name);
353 name=xstrdup(optarg); 350 name=xstrdup(optarg);
354 break; 351 break;
355 case 'q': 352 case 'q':
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 29e2e3b66..391d245a8 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -158,10 +158,8 @@ static void mtab_free(void)
158 this = mtab_cache; 158 this = mtab_cache;
159 while (this) { 159 while (this) {
160 next = this->next; 160 next = this->next;
161 if (this->device) 161 free(this->device);
162 free(this->device); 162 free(this->mountpt);
163 if (this->mountpt)
164 free(this->mountpt);
165 free(this); 163 free(this);
166 this = next; 164 this = next;
167 } 165 }