ash: [VAR] Fix poplocalvar leak

Upstream commit:

    Date: Tue, 25 May 2010 18:14:32 +0800
    [VAR] Fix poplocalvar leak

    When a variable is marked as local, we set VSTRFIXED on its vp
    recored.  However, poplocalvar never clears this flag for variables
    that were unset to begin with.  Thus if you ever made an unset
    variable local, it would get the VSTRFIXED bit and stick around
    forever.

    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-07-26 19:25:40 +02:00
parent b8ab27bf53
commit d5b500c81c

View File

@ -9200,7 +9200,8 @@ poplocalvars(void)
memcpy(optlist, lvp->text, sizeof(optlist));
free((char*)lvp->text);
optschanged();
} else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) {
} else if (lvp->flags == VUNSET) {
vp->flags &= ~(VSTRFIXED|VREADONLY);
unsetvar(vp->var_text);
} else {
if (vp->var_func)