From c1762f49320fe07484d9ab671ffb0cf3813414dd Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 1 Mar 2007 16:16:04 +0000 Subject: * generic/tclCmdAH.c (Tcl_ForeachObjCmd): Rewrite to make efficient private copies of the variable and value lists, so we can operate on them without any special shimmer defense coding schemes. --- ChangeLog | 6 ++++++ generic/tclCmdAH.c | 54 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65469d4..547601e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-03-01 Don Porter + + * generic/tclCmdAH.c (Tcl_ForeachObjCmd): Rewrite to make + efficient private copies of the variable and value lists, so we can + operate on them without any special shimmer defense coding schemes. + 2007-03-01 Donal K. Fellows * generic/tclCompCmds.c (TclCompileForeachCmd): Prevent an unexpected diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index a179357..a017a2d 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdAH.c,v 1.83 2007/02/26 19:10:32 dgp Exp $ + * RCS: @(#) $Id: tclCmdAH.c,v 1.84 2007/03/01 16:16:04 dgp Exp $ */ #include "tclInt.h" @@ -1703,14 +1703,18 @@ Tcl_ForeachObjCmd( int indexArray[STATIC_LIST_SIZE]; int varcListArray[STATIC_LIST_SIZE]; Tcl_Obj **varvListArray[STATIC_LIST_SIZE]; + Tcl_Obj *vCopyListArray[STATIC_LIST_SIZE]; int argcListArray[STATIC_LIST_SIZE]; Tcl_Obj **argvListArray[STATIC_LIST_SIZE]; + Tcl_Obj *aCopyListArray[STATIC_LIST_SIZE]; int *index = indexArray; /* Array of value list indices */ int *varcList = varcListArray; /* # loop variables per list */ Tcl_Obj ***varvList = varvListArray;/* Array of var name lists */ + Tcl_Obj **vCopyList = vCopyListArray; /* Copies of var name list arguments */ int *argcList = argcListArray; /* Array of value list sizes */ Tcl_Obj ***argvList = argvListArray;/* Array of value lists */ + Tcl_Obj **aCopyList = aCopyListArray; /* Copies of value list arguments */ Interp *iPtr = (Interp *) interp; if (objc < 4 || (objc%2 != 0)) { @@ -1732,15 +1736,19 @@ Tcl_ForeachObjCmd( index = (int *) ckalloc(numLists * sizeof(int)); varcList = (int *) ckalloc(numLists * sizeof(int)); varvList = (Tcl_Obj ***) ckalloc(numLists * sizeof(Tcl_Obj **)); + vCopyList = (Tcl_Obj **) ckalloc(numLists * sizeof(Tcl_Obj *)); argcList = (int *) ckalloc(numLists * sizeof(int)); argvList = (Tcl_Obj ***) ckalloc(numLists * sizeof(Tcl_Obj **)); + aCopyList = (Tcl_Obj **) ckalloc(numLists * sizeof(Tcl_Obj *)); } for (i = 0; i < numLists; i++) { index[i] = 0; varcList[i] = 0; varvList[i] = NULL; + vCopyList[i] = NULL; argcList[i] = 0; argvList[i] = NULL; + aCopyList[i] = NULL; } /* @@ -1749,22 +1757,25 @@ Tcl_ForeachObjCmd( maxj = 0; for (i=0 ; i STATIC_LIST_SIZE) { ckfree((char *) index); ckfree((char *) varcList); ckfree((char *) argcList); ckfree((char *) varvList); ckfree((char *) argvList); + ckfree((char *) vCopyList); + ckfree((char *) aCopyList); } return result; #undef STATIC_LIST_SIZE -- cgit v0.12