diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2002-09-04 15:18:53 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2002-09-04 15:18:53 (GMT) |
commit | c3cc9f4c14bd37ca383d4db3187bfee07797bed4 (patch) | |
tree | af258853eff043b1f04aa10b4ff24a52f07c2d5a /generic/tclVar.c | |
parent | 555b41ab33cffe4edf21f22dbc17c6c4bd3a1459 (diff) | |
download | tcl-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.
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r-- | generic/tclVar.c | 15 |
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 */ } |