summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2002-09-04 15:18:53 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2002-09-04 15:18:53 (GMT)
commitc3cc9f4c14bd37ca383d4db3187bfee07797bed4 (patch)
treeaf258853eff043b1f04aa10b4ff24a52f07c2d5a
parent555b41ab33cffe4edf21f22dbc17c6c4bd3a1459 (diff)
downloadtcl-c3cc9f4c14bd37ca383d4db3187bfee07797bed4.zip
tcl-c3cc9f4c14bd37ca383d4db3187bfee07797bed4.tar.gz
tcl-c3cc9f4c14bd37ca383d4db3187bfee07797bed4.tar.bz2
* generic/tclVar.c (DeleteArray): leak plug [Bug 604239]. Thanks
to dkf and dgp for the long and difficult discussion in the chat.
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclVar.c15
2 files changed, 19 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0c2a2a2..d49c675 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2002-09-04 Miguel Sofer <msofer@users.sourceforge.net>
+
+ * generic/tclVar.c (DeleteArray): leak plug [Bug 604239]. Thanks
+ to dkf and dgp for the long and difficult discussion in the chat.
+
2002-09-03 Jeff Hobbs <jeffh@ActiveState.com>
* generic/tclVar.c (Tcl_UpVar2): code cleanup to not use goto
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 516a558..9854161 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.65 2002/09/03 19:52:01 hobbs Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.66 2002/09/04 15:18:53 msofer Exp $
*/
#include "tclInt.h"
@@ -4783,6 +4783,19 @@ DeleteArray(iPtr, arrayName, varPtr, flags)
}
TclSetVarUndefined(elPtr);
TclSetVarScalar(elPtr);
+
+ /*
+ * Even though array elements are not supposed to be namespace
+ * variables, some combinations of [upvar] and [variable] may
+ * create such beasts - see [Bug 604239]. This is necessary to
+ * avoid leaking the corresponding Var struct, and is otherwise
+ * harmless.
+ */
+
+ if (elPtr->flags & VAR_NAMESPACE_VAR) {
+ elPtr->flags &= ~VAR_NAMESPACE_VAR;
+ elPtr->refCount--;
+ }
if (elPtr->refCount == 0) {
ckfree((char *) elPtr); /* element Vars are VAR_IN_HASHTABLE */
}