From: Ron Yorston Date: Fri, 30 Oct 2015 19:07:37 +0000 (+0000) Subject: ash: allow popredir to be called if the stack is empty X-Git-Tag: 1_25_0~169 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=95650a86d176ee83a264fd9e7047c414b71ee7cb;p=oweals%2Fbusybox.git ash: allow popredir to be called if the stack is empty If /tmp/test.sh is a script that tries to run a second script which happens to be non-executable this: command . /tmp/test.sh causes a seg fault. This is because clearredir is called in the error path to clear the stack of redirections. The normal path then calls popredir, but popredir fails when the stack is empty. Reported-by: Bastian Bittorf Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- diff --git a/shell/ash.c b/shell/ash.c index c333b235b..84502636a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5409,7 +5409,7 @@ popredir(int drop, int restore) struct redirtab *rp; int i; - if (--g_nullredirs >= 0) + if (--g_nullredirs >= 0 || redirlist == NULL) return; INT_OFF; rp = redirlist;