From 55ffc36246d6536cd81e44f3c8c32bd3cd04afb8 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 25 May 2010 18:14:32 +0800 Subject: [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 --- src/var.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/var.c b/src/var.c index de1a5f5..fc6d367 100644 --- a/src/var.c +++ b/src/var.c @@ -543,7 +543,8 @@ poplocalvars(void) memcpy(optlist, lvp->text, sizeof(optlist)); ckfree(lvp->text); optschanged(); - } else if ((lvp->flags & (VUNSET|VSTRFIXED)) == VUNSET) { + } else if (lvp->flags == VUNSET) { + vp->flags &= ~(VSTRFIXED|VREADONLY); unsetvar(vp->text); } else { if (vp->func) @@ -627,8 +628,6 @@ unsetvar(const char *s) retval = 1; if (flags & VREADONLY) goto out; - if (flags & VUNSET) - goto ok; if ((flags & VSTRFIXED) == 0) { INTOFF; if ((flags & (VTEXTFIXED|VSTACK)) == 0) @@ -636,11 +635,10 @@ unsetvar(const char *s) *vpp = vp->next; ckfree(vp); INTON; - } else { + } else if (!(flags & VUNSET)) { setvar(s, 0, 0); vp->flags &= ~VEXPORT; } -ok: retval = 0; } -- cgit 1.4.1 fc5c29845fbee4a4091fd2d5deaa36a'/>
Commit message (Expand)Author
2018-05-13Clean up modem loopJune McEnroe
2018-05-13Add modemJune McEnroe
2018-05-13Tabify binJune McEnroe
2018-05-13Tabify shell scriptsJune McEnroe
2018-05-13I've really done it nowJune McEnroe
2018-05-11Link with -lmJune McEnroe
2018-04-26Add UtopioidJune McEnroe