diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-06 22:17:29 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-06 22:17:29 +0000 |
| commit | d18525c4d9d88c8d6d2f2f71e9fc892bfa129d18 (patch) | |
| tree | bb59e4863e4a72995f19364b9709c36e827d4a30 /shell | |
| parent | 1dfbb3d59511b9f0d81d8e1ef97fa20ed8463f95 (diff) | |
| download | busybox-w32-d18525c4d9d88c8d6d2f2f71e9fc892bfa129d18.tar.gz busybox-w32-d18525c4d9d88c8d6d2f2f71e9fc892bfa129d18.tar.bz2 busybox-w32-d18525c4d9d88c8d6d2f2f71e9fc892bfa129d18.zip | |
Fix the memory leak. No really this time.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@1989 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/lash.c | 16 |
1 files changed, 9 insertions, 7 deletions
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; | |||
| 207 | static struct jobset job_list = { NULL, NULL }; | 207 | static struct jobset job_list = { NULL, NULL }; |
| 208 | static int argc; | 208 | static int argc; |
| 209 | static char **argv; | 209 | static char **argv; |
| 210 | static struct close_me *close_me_head = NULL; | 210 | static struct close_me *close_me_head; |
| 211 | #ifdef BB_FEATURE_SH_ENVIRONMENT | 211 | #ifdef BB_FEATURE_SH_ENVIRONMENT |
| 212 | static int last_bg_pid=-1; | 212 | static int last_bg_pid=-1; |
| 213 | static int last_return_code=-1; | 213 | static int last_return_code=-1; |
| @@ -631,9 +631,12 @@ static void mark_closed(int fd) | |||
| 631 | 631 | ||
| 632 | static void close_all() | 632 | static 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; |
