diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-12 06:47:39 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-12 06:47:39 +0100 |
commit | 385cc59117f2788d24d2cd75fd58f7ff044d501c (patch) | |
tree | 39eac0ffef23597671466a3399077c9d4269445a | |
parent | 65d722bb0d0e822db014a742da4c9c2c111131f0 (diff) | |
download | busybox-w32-385cc59117f2788d24d2cd75fd58f7ff044d501c.tar.gz busybox-w32-385cc59117f2788d24d2cd75fd58f7ff044d501c.tar.bz2 busybox-w32-385cc59117f2788d24d2cd75fd58f7ff044d501c.zip |
hush: plug a memory leak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 1 | ||||
-rw-r--r-- | shell/hush_test/hush-z_slow/leak_empty_tick.right | 3 | ||||
-rwxr-xr-x | shell/hush_test/hush-z_slow/leak_empty_tick.tests | 28 |
3 files changed, 32 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c index 25094654d..d02e68d49 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4136,6 +4136,7 @@ static NOINLINE int run_pipe(struct pipe *pi) | |||
4136 | 4136 | ||
4137 | /* if someone gives us an empty string: `cmd with empty output` */ | 4137 | /* if someone gives us an empty string: `cmd with empty output` */ |
4138 | if (!argv_expanded[0]) { | 4138 | if (!argv_expanded[0]) { |
4139 | free(argv_expanded); | ||
4139 | debug_leave(); | 4140 | debug_leave(); |
4140 | return G.last_exitcode; | 4141 | return G.last_exitcode; |
4141 | } | 4142 | } |
diff --git a/shell/hush_test/hush-z_slow/leak_empty_tick.right b/shell/hush_test/hush-z_slow/leak_empty_tick.right new file mode 100644 index 000000000..c6f0334f3 --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_empty_tick.right | |||
@@ -0,0 +1,3 @@ | |||
1 | Warm up | ||
2 | Measuring memory leak... | ||
3 | Ok | ||
diff --git a/shell/hush_test/hush-z_slow/leak_empty_tick.tests b/shell/hush_test/hush-z_slow/leak_empty_tick.tests new file mode 100755 index 000000000..ae3757969 --- /dev/null +++ b/shell/hush_test/hush-z_slow/leak_empty_tick.tests | |||
@@ -0,0 +1,28 @@ | |||
1 | echo "Warm up" | ||
2 | i=1 | ||
3 | while test $i != 9; do | ||
4 | `true` | ||
5 | : $((i++)) | ||
6 | done | ||
7 | |||
8 | memleak | ||
9 | |||
10 | echo "Measuring memory leak..." | ||
11 | i=1 | ||
12 | while test $i != 199; do | ||
13 | `true` | ||
14 | : $((i++)) | ||
15 | done | ||
16 | i=1 | ||
17 | while test $i != 199; do | ||
18 | `true` | ||
19 | : $((i++)) | ||
20 | done | ||
21 | |||
22 | memleak | ||
23 | kb=$? | ||
24 | if test $kb -le 4; then | ||
25 | echo Ok #$kb | ||
26 | else | ||
27 | echo "Bad: $kb kb (or more) leaked" | ||
28 | fi | ||