bug-report: ash: fix a memory leak

yhu2 yadi.hu at windriver.com
Wed Dec 24 02:32:19 UTC 2014


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,any commnent 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;


  



More information about the busybox mailing list