diff options
author | jilles <jilles@FreeBSD.org> | 2013-02-19 23:46:51 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-02-19 23:46:51 +0000 |
commit | d08a4b37f124c7155aa6d83f51bd25d2b295ea71 (patch) | |
tree | 7238f9fc77b9dbc1580c91b360e161731bffaca2 /bin | |
parent | fa192d80dd36d15b97e60e3f59d9c0a37e8439d5 (diff) | |
download | FreeBSD-src-d08a4b37f124c7155aa6d83f51bd25d2b295ea71.zip FreeBSD-src-d08a4b37f124c7155aa6d83f51bd25d2b295ea71.tar.gz |
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
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/eval.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 66ae40e..b40fffd 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -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); |