ash: consider "local -" case while iterating over local variables in mklocal.
authorEugene Rudoy <gene.devel@gmail.com>
Sun, 26 Apr 2015 21:32:00 +0000 (23:32 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 13 May 2015 00:09:53 +0000 (02:09 +0200)
fixes segfault introduced in 0a0acb55db8d7c4dec445573f1b0528d126b9e1f with functions using "local -".
test-case: f() { local -; local x; }; f

note: with this change applied multiple 'local -'s still cause multiple entries to be added to the localvars list.
this problem will be addressed in a separate commit.

Signed-off-by: Eugene Rudoy <gene.devel@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index c51fb804d83f0290c4102d224b742758265d21ee..3e9997b5312f3a94186b3900c90a590bb418c574 100644 (file)
@@ -8979,7 +8979,7 @@ mklocal(char *name)
         */
        lvp = localvars;
        while (lvp) {
-               if (varcmp(lvp->vp->var_text, name) == 0) {
+               if (lvp->vp && varcmp(lvp->vp->var_text, name) == 0) {
                        if (eq)
                                setvareq(name, 0);
                        /* else: