[PATCH 2/4] [VAR] Fix poplocalvar leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[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@xxxxxxxxxxxxxxxxxxx>
---

 ChangeLog |    4 ++++
 src/var.c |    8 +++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7285a23..f3c7701 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-25  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
+
+	* Fix poplocalvar leak.
+
 2010-05-24  Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
 
 	* Add localvars nesting.
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;
 	}
 
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux