svn commit: r247013 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Tue Feb 19 23:46:52 UTC 2013


Author: jilles
Date: Tue Feb 19 23:46:51 2013
New Revision: 247013
URL: http://svnweb.freebsd.org/changeset/base/247013

Log:
  sh: Fix a crash with the stackmark code.
  
  If a stack mark is set while the current stack block is empty, the stack
  block may move later on (because of realloc()) and the stack mark needs to
  be updated. This updating does not happen after popstackmark() has been
  called; therefore, call setstackmark() again if the stack mark is still
  being used.
  
  For some reason, this only affects a few users. I cannot reproduce it. The
  situation seems quite rare as well because an empty stack block would
  usually be freed (by popstackmark()) before execution reaches a
  setstackmark() call.
  
  PR:		175922
  Tested by:	KT Sin

Modified:
  head/bin/sh/eval.c

Modified: head/bin/sh/eval.c
==============================================================================
--- head/bin/sh/eval.c	Tue Feb 19 21:35:17 2013	(r247012)
+++ head/bin/sh/eval.c	Tue Feb 19 23:46:51 2013	(r247013)
@@ -174,6 +174,7 @@ evalstring(char *s, int flags)
 			any = 1;
 		}
 		popstackmark(&smark);
+		setstackmark(&smark);
 	}
 	popfile();
 	popstackmark(&smark);
@@ -296,6 +297,7 @@ evaltree(union node *n, int flags)
 		}
 		n = next;
 		popstackmark(&smark);
+		setstackmark(&smark);
 	} while (n != NULL);
 out:
 	popstackmark(&smark);


More information about the svn-src-all mailing list