summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-12 05:47:39 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2010-01-12 05:47:39 (GMT)
commit385cc59117f2788d24d2cd75fd58f7ff044d501c (patch)
tree39eac0ffef23597671466a3399077c9d4269445a
parent65d722bb0d0e822db014a742da4c9c2c111131f0 (diff)
downloadbusybox-385cc59117f2788d24d2cd75fd58f7ff044d501c.tar.gz
busybox-385cc59117f2788d24d2cd75fd58f7ff044d501c.tar.bz2
hush: plug a memory leak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c1
-rw-r--r--shell/hush_test/hush-z_slow/leak_empty_tick.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_empty_tick.tests28
3 files changed, 32 insertions, 0 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 2509465..d02e68d 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4136,6 +4136,7 @@ static NOINLINE int run_pipe(struct pipe *pi)
/* if someone gives us an empty string: `cmd with empty output` */
if (!argv_expanded[0]) {
+ free(argv_expanded);
debug_leave();
return G.last_exitcode;
}
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 0000000..c6f0334
--- /dev/null
+++ b/shell/hush_test/hush-z_slow/leak_empty_tick.right
@@ -0,0 +1,3 @@
+Warm up
+Measuring memory leak...
+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 0000000..ae37579
--- /dev/null
+++ b/shell/hush_test/hush-z_slow/leak_empty_tick.tests
@@ -0,0 +1,28 @@
+echo "Warm up"
+i=1
+while test $i != 9; do
+ `true`
+ : $((i++))
+done
+
+memleak
+
+echo "Measuring memory leak..."
+i=1
+while test $i != 199; do
+ `true`
+ : $((i++))
+done
+i=1
+while test $i != 199; do
+ `true`
+ : $((i++))
+done
+
+memleak
+kb=$?
+if test $kb -le 4; then
+ echo Ok #$kb
+else
+ echo "Bad: $kb kb (or more) leaked"
+fi