aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-06 22:17:29 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-06 22:17:29 +0000
commit702ec5926f86653b5a20b7d856de6b3a4c11516f (patch)
treebb59e4863e4a72995f19364b9709c36e827d4a30
parent8bb7df49c24de71f28b47eb2e3b86fb5b2e9d42a (diff)
downloadbusybox-w32-702ec5926f86653b5a20b7d856de6b3a4c11516f.tar.gz
busybox-w32-702ec5926f86653b5a20b7d856de6b3a4c11516f.tar.bz2
busybox-w32-702ec5926f86653b5a20b7d856de6b3a4c11516f.zip
Fix the memory leak. No really this time.
-Erik
-rw-r--r--lash.c16
-rw-r--r--sh.c16
-rw-r--r--shell/lash.c16
3 files changed, 27 insertions, 21 deletions
diff --git a/lash.c b/lash.c
index b7c5ec525..72d8bb38b 100644
--- a/lash.c
+++ b/lash.c
@@ -207,7 +207,7 @@ static char *local_pending_command = NULL;
207static struct jobset job_list = { NULL, NULL }; 207static struct jobset job_list = { NULL, NULL };
208static int argc; 208static int argc;
209static char **argv; 209static char **argv;
210static struct close_me *close_me_head = NULL; 210static struct close_me *close_me_head;
211#ifdef BB_FEATURE_SH_ENVIRONMENT 211#ifdef BB_FEATURE_SH_ENVIRONMENT
212static int last_bg_pid=-1; 212static int last_bg_pid=-1;
213static int last_return_code=-1; 213static int last_return_code=-1;
@@ -631,9 +631,12 @@ static void mark_closed(int fd)
631 631
632static void close_all() 632static void close_all()
633{ 633{
634 struct close_me *c; 634 int i=0;
635 for (c=close_me_head; c; c=c->next) { 635 struct close_me *c, *tmp;
636 mark_closed(c->fd); 636 for (c=close_me_head; c; c=tmp) {
637 close(c->fd);
638 tmp=c->next;
639 free(c);
637 } 640 }
638 close_me_head = NULL; 641 close_me_head = NULL;
639} 642}
@@ -1713,11 +1716,11 @@ int shell_main(int argc_l, char **argv_l)
1713 argc = argc_l; 1716 argc = argc_l;
1714 argv = argv_l; 1717 argv = argv_l;
1715 1718
1719 /* These variables need re-initializing when recursing */
1716 shell_context = 0; 1720 shell_context = 0;
1717 cwd=NULL; 1721 cwd=NULL;
1718#ifdef BB_FEATURE_SH_STANDALONE_SHELL
1719 /* These variables need re-initializing when recursing */
1720 local_pending_command = NULL; 1722 local_pending_command = NULL;
1723 close_me_head = NULL;
1721 job_list.head = NULL; 1724 job_list.head = NULL;
1722 job_list.fg = NULL; 1725 job_list.fg = NULL;
1723#ifdef BB_FEATURE_SH_ENVIRONMENT 1726#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1725,7 +1728,6 @@ int shell_main(int argc_l, char **argv_l)
1725 last_return_code=-1; 1728 last_return_code=-1;
1726 show_x_trace=FALSE; 1729 show_x_trace=FALSE;
1727#endif 1730#endif
1728#endif
1729 1731
1730 if (argv[0] && argv[0][0] == '-') { 1732 if (argv[0] && argv[0][0] == '-') {
1731 FILE *prof_input; 1733 FILE *prof_input;
diff --git a/sh.c b/sh.c
index b7c5ec525..72d8bb38b 100644
--- a/sh.c
+++ b/sh.c
@@ -207,7 +207,7 @@ static char *local_pending_command = NULL;
207static struct jobset job_list = { NULL, NULL }; 207static struct jobset job_list = { NULL, NULL };
208static int argc; 208static int argc;
209static char **argv; 209static char **argv;
210static struct close_me *close_me_head = NULL; 210static struct close_me *close_me_head;
211#ifdef BB_FEATURE_SH_ENVIRONMENT 211#ifdef BB_FEATURE_SH_ENVIRONMENT
212static int last_bg_pid=-1; 212static int last_bg_pid=-1;
213static int last_return_code=-1; 213static int last_return_code=-1;
@@ -631,9 +631,12 @@ static void mark_closed(int fd)
631 631
632static void close_all() 632static void close_all()
633{ 633{
634 struct close_me *c; 634 int i=0;
635 for (c=close_me_head; c; c=c->next) { 635 struct close_me *c, *tmp;
636 mark_closed(c->fd); 636 for (c=close_me_head; c; c=tmp) {
637 close(c->fd);
638 tmp=c->next;
639 free(c);
637 } 640 }
638 close_me_head = NULL; 641 close_me_head = NULL;
639} 642}
@@ -1713,11 +1716,11 @@ int shell_main(int argc_l, char **argv_l)
1713 argc = argc_l; 1716 argc = argc_l;
1714 argv = argv_l; 1717 argv = argv_l;
1715 1718
1719 /* These variables need re-initializing when recursing */
1716 shell_context = 0; 1720 shell_context = 0;
1717 cwd=NULL; 1721 cwd=NULL;
1718#ifdef BB_FEATURE_SH_STANDALONE_SHELL
1719 /* These variables need re-initializing when recursing */
1720 local_pending_command = NULL; 1722 local_pending_command = NULL;
1723 close_me_head = NULL;
1721 job_list.head = NULL; 1724 job_list.head = NULL;
1722 job_list.fg = NULL; 1725 job_list.fg = NULL;
1723#ifdef BB_FEATURE_SH_ENVIRONMENT 1726#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1725,7 +1728,6 @@ int shell_main(int argc_l, char **argv_l)
1725 last_return_code=-1; 1728 last_return_code=-1;
1726 show_x_trace=FALSE; 1729 show_x_trace=FALSE;
1727#endif 1730#endif
1728#endif
1729 1731
1730 if (argv[0] && argv[0][0] == '-') { 1732 if (argv[0] && argv[0][0] == '-') {
1731 FILE *prof_input; 1733 FILE *prof_input;
diff --git a/shell/lash.c b/shell/lash.c
index b7c5ec525..72d8bb38b 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -207,7 +207,7 @@ static char *local_pending_command = NULL;
207static struct jobset job_list = { NULL, NULL }; 207static struct jobset job_list = { NULL, NULL };
208static int argc; 208static int argc;
209static char **argv; 209static char **argv;
210static struct close_me *close_me_head = NULL; 210static struct close_me *close_me_head;
211#ifdef BB_FEATURE_SH_ENVIRONMENT 211#ifdef BB_FEATURE_SH_ENVIRONMENT
212static int last_bg_pid=-1; 212static int last_bg_pid=-1;
213static int last_return_code=-1; 213static int last_return_code=-1;
@@ -631,9 +631,12 @@ static void mark_closed(int fd)
631 631
632static void close_all() 632static void close_all()
633{ 633{
634 struct close_me *c; 634 int i=0;
635 for (c=close_me_head; c; c=c->next) { 635 struct close_me *c, *tmp;
636 mark_closed(c->fd); 636 for (c=close_me_head; c; c=tmp) {
637 close(c->fd);
638 tmp=c->next;
639 free(c);
637 } 640 }
638 close_me_head = NULL; 641 close_me_head = NULL;
639} 642}
@@ -1713,11 +1716,11 @@ int shell_main(int argc_l, char **argv_l)
1713 argc = argc_l; 1716 argc = argc_l;
1714 argv = argv_l; 1717 argv = argv_l;
1715 1718
1719 /* These variables need re-initializing when recursing */
1716 shell_context = 0; 1720 shell_context = 0;
1717 cwd=NULL; 1721 cwd=NULL;
1718#ifdef BB_FEATURE_SH_STANDALONE_SHELL
1719 /* These variables need re-initializing when recursing */
1720 local_pending_command = NULL; 1722 local_pending_command = NULL;
1723 close_me_head = NULL;
1721 job_list.head = NULL; 1724 job_list.head = NULL;
1722 job_list.fg = NULL; 1725 job_list.fg = NULL;
1723#ifdef BB_FEATURE_SH_ENVIRONMENT 1726#ifdef BB_FEATURE_SH_ENVIRONMENT
@@ -1725,7 +1728,6 @@ int shell_main(int argc_l, char **argv_l)
1725 last_return_code=-1; 1728 last_return_code=-1;
1726 show_x_trace=FALSE; 1729 show_x_trace=FALSE;
1727#endif 1730#endif
1728#endif
1729 1731
1730 if (argv[0] && argv[0][0] == '-') { 1732 if (argv[0] && argv[0][0] == '-') {
1731 FILE *prof_input; 1733 FILE *prof_input;