diff options
author | dgp <dgp@users.sourceforge.net> | 2007-03-12 18:06:13 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-03-12 18:06:13 (GMT) |
commit | 0a78bbbd2192fb9210fb701537a53b9bf225c8dd (patch) | |
tree | 99c595705af12340ce3dbbb67bd55039aafabe4a /generic/tclVar.c | |
parent | 9a2dce2fe1de8870e0fcbe8a8693b762065a336c (diff) | |
download | tcl-0a78bbbd2192fb9210fb701537a53b9bf225c8dd.zip tcl-0a78bbbd2192fb9210fb701537a53b9bf225c8dd.tar.gz tcl-0a78bbbd2192fb9210fb701537a53b9bf225c8dd.tar.bz2 |
* generic/tclVar.c (TclArraySet): Make efficient private copy of
* tests/var.test (var-17.1): the "list" argument to [array set] to
avoid crash due to shimmering invalidating pointers. [Bug 1669489].
Diffstat (limited to 'generic/tclVar.c')
-rw-r--r-- | generic/tclVar.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/generic/tclVar.c b/generic/tclVar.c index 13d5dc6..17b859c 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.127 2007/02/20 23:24:03 nijtmans Exp $ + * RCS: @(#) $Id: tclVar.c,v 1.128 2007/03/12 18:06:14 dgp Exp $ */ #include "tclInt.h" @@ -3023,8 +3023,7 @@ TclArraySet( * NULL, create an empty array. */ { Var *varPtr, *arrayPtr; - Tcl_Obj **elemPtrs; - int result, elemLen, i, nameLen; + int result, i, nameLen; char *varName, *p; varName = Tcl_GetStringFromObj(arrayNameObj, &nameLen); @@ -3100,6 +3099,8 @@ TclArraySet( * Not a dictionary, so assume (and convert to, for * backward-compatability reasons) a list. */ + int elemLen; + Tcl_Obj **elemPtrs, *copyListObj; result = Tcl_ListObjGetElements(interp, arrayElemObj, &elemLen, &elemPtrs); @@ -3121,6 +3122,7 @@ TclArraySet( * loop and return an error. */ + copyListObj = TclListObjCopy(NULL, arrayElemObj); for (i=0 ; i<elemLen ; i+=2) { char *part2 = TclGetString(elemPtrs[i]); Var *elemVarPtr = TclLookupArrayElement(interp, varName, @@ -3133,6 +3135,7 @@ TclArraySet( break; } } + Tcl_DecrRefCount(copyListObj); return result; } |