[Bug 7748] New: ash: fix a memory leak

Yuki Machida machida.yuki at jp.fujitsu.com
Wed Nov 21 01:39:59 UTC 2018


Hi all,

Please merge a patch to upstream of busybox.

Following patch is applied to busybobx 03ad7ae08.
(Modified with reference to http://lists.busybox.net/pipermail/busybox-cvs/2014-December/034873.html)
I confirmed that fix a memory leak.

diff --git shell/ash.c shell/ash.c
index 04e4006c8..6bd849568 100644
--- shell/ash.c
+++ shell/ash.c
@@ -9049,6 +9049,7 @@ evaltree(union node *n, int flags)
         int checkexit = 0;
         int (*evalfn)(union node *, int);
         int status = 0;
+       struct stackmark smark;

         if (n == NULL) {
                 TRACE(("evaltree(NULL) called\n"));
@@ -9069,6 +9070,7 @@ evaltree(union node *n, int flags)
                 status = !evaltree(n->nnot.com, EV_TESTED);
                 goto setstatus;
         case NREDIR:
+               setstackmark(&smark);
                 errlinno = lineno = n->nredir.linno;
                 if (funcline)
                         lineno -= funcline - 1;
@@ -9080,6 +9082,7 @@ evaltree(union node *n, int flags)
                 }
                 if (n->nredir.redirect)
                         popredir(/*drop:*/ 0);
+               popstackmark(&smark);
                 goto setstatus;
         case NCMD:
                 evalfn = evalcommand;

Best regards,
Yuki Machida



More information about the busybox mailing list