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

bugzilla at busybox.net bugzilla at busybox.net
Wed Dec 24 02:39:38 UTC 2014


https://bugs.busybox.net/show_bug.cgi?id=7748

           Summary: ash: fix a memory leak
           Product: Busybox
           Version: unspecified
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P5
         Component: Other
        AssignedTo: unassigned at busybox.net
        ReportedBy: yadi.hu at windriver.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0


The script which triggers the leak:

while true
  do
    while true
      do
        break;
    done</dev/null
done

someone had fixed this bug, the commit is:

http://git.busybox.net/busybox/commit/shell/ash.c?id=4ba6c5d3ba3d2c7922aff6b5c2e73b8325f1cf17

but this commit results in crash running some shell scripts, so it was
reverted.


I am trying to resolve this defect,below is a patch, any comments would be
appreciated!

--- shell/ash.c    2011-03-13 09:45:40.000000000 +0800
+++ shell/ash.c    2014-12-23 17:34:04.000000000 +0800
@@ -8290,6 +8290,7 @@
     void (*evalfn)(union node *, int);
     int status;
     int int_level;
+    struct stackmark smark;

     SAVE_INT(int_level);

@@ -8329,6 +8330,7 @@
         status = !exitstatus;
         goto setstatus;
     case NREDIR:
+        setstackmark(&smark);
         expredir(n->nredir.redirect);
         status = redirectsafe(n->nredir.redirect, REDIR_PUSH);
         if (!status) {
@@ -8336,6 +8338,7 @@
             status = exitstatus;
         }
         popredir(/*drop:*/ 0, /*restore:*/ 0 /* not sure */);
+        popstackmark(&smark);
         goto setstatus;
     case NCMD:
         evalfn = evalcommand;

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list