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
This commit is contained in:
Jilles Tjoelker 2013-02-19 23:46:51 +00:00
parent c9ad522755
commit e9e9223546

View File

@ -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);