summaryrefslogtreecommitdiffstats
path: root/generic/tclVar.c
diff options
context:
space:
mode:
authormsofer <msofer@noemail.net>2002-09-04 15:18:53 (GMT)
committermsofer <msofer@noemail.net>2002-09-04 15:18:53 (GMT)
commite6317236a4536bce3c36694afd134add51f2afdb (patch)
treeaf258853eff043b1f04aa10b4ff24a52f07c2d5a /generic/tclVar.c
parent3357022c2292f18699a9cde8effcc8bc436edb08 (diff)
downloadtcl-e6317236a4536bce3c36694afd134add51f2afdb.zip
tcl-e6317236a4536bce3c36694afd134add51f2afdb.tar.gz
tcl-e6317236a4536bce3c36694afd134add51f2afdb.tar.bz2
* generic/tclVar.c (DeleteArray): leak plug [Bug 604239]. Thanks
to dkf and dgp for the long and difficult discussion in the chat. FossilOrigin-Name: 2e3caf062150711b9e9ee168a74d91d6194bcde5
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r--generic/tclVar.c15
1 files changed, 14 insertions, 1 deletions
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 */
}