summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-05-12 22:44:23 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-05-12 22:44:23 (GMT)
commit3fa0ae44eb7b084cc0591023606dc593cdc8169c (patch)
treec573f9eb88f9a33584de27587d7b44ec7ee8bec9
parent848f3e85419c57c034cd7ebe11918e835f04782b (diff)
downloadtcl-3fa0ae44eb7b084cc0591023606dc593cdc8169c.zip
tcl-3fa0ae44eb7b084cc0591023606dc593cdc8169c.tar.gz
tcl-3fa0ae44eb7b084cc0591023606dc593cdc8169c.tar.bz2
* generic/tclInterp.c: (AliasObjCmd): Added refCounting of the words
* tests/interp.test (interp-33.1): of the target of an interp alias during its execution. Also added test. [Bug 730244].
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclInterp.c10
-rw-r--r--tests/interp.test11
3 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index aa942ef..9a2823c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2003-05-12 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclInterp.c: (AliasObjCmd): Added refCounting of the words
+ * tests/interp.test (interp-33.1): of the target of an interp
+ alias during its execution. Also added test. [Bug 730244].
+
* generic/tclBasic.c (TclInvokeObjectCommand): objv[argc] is no
longer set to NULL (Tcl_CreateObjCommand docs already say that it
should not be accessed).
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index b8f1fe2..8159855 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInterp.c,v 1.21 2003/03/12 17:52:36 dgp Exp $
+ * RCS: @(#) $Id: tclInterp.c,v 1.22 2003/05/12 22:44:24 dgp Exp $
*/
#include "tclInt.h"
@@ -1446,7 +1446,7 @@ AliasObjCmd(clientData, interp, objc, objv)
#define ALIAS_CMDV_PREALLOC 10
Tcl_Interp *targetInterp;
Alias *aliasPtr;
- int result, prefc, cmdc;
+ int result, prefc, cmdc, i;
Tcl_Obj **prefv, **cmdv;
Tcl_Obj *cmdArr[ALIAS_CMDV_PREALLOC];
aliasPtr = (Alias *) clientData;
@@ -1474,6 +1474,9 @@ AliasObjCmd(clientData, interp, objc, objv)
Tcl_ResetResult(targetInterp);
+ for (i=0; i<cmdc; i++) {
+ Tcl_IncrRefCount(cmdv[i]);
+ }
if (targetInterp != interp) {
Tcl_Preserve((ClientData) targetInterp);
result = Tcl_EvalObjv(targetInterp, cmdc, cmdv, TCL_EVAL_INVOKE);
@@ -1482,6 +1485,9 @@ AliasObjCmd(clientData, interp, objc, objv)
} else {
result = Tcl_EvalObjv(targetInterp, cmdc, cmdv, TCL_EVAL_INVOKE);
}
+ for (i=0; i<cmdc; i++) {
+ Tcl_DecrRefCount(cmdv[i]);
+ }
if (cmdv != cmdArr) {
ckfree((char *) cmdv);
diff --git a/tests/interp.test b/tests/interp.test
index 5ce02d6..7c1c78c 100644
--- a/tests/interp.test
+++ b/tests/interp.test
@@ -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: interp.test,v 1.21 2003/05/05 16:48:54 dkf Exp $
+# RCS: @(#) $Id: interp.test,v 1.22 2003/05/12 22:44:24 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2.1
@@ -2919,6 +2919,15 @@ test interp-32.1 { parent's working directory should
"\{$parent\} != \{$child\}"}
} 1
+test interp-33.1 {refCounting for target words of alias [Bug 730244]} {
+ # This test will panic if Bug 730244 is not fixed.
+ interp create i
+ proc test args {return $args}
+ trace add execution test enter {interp alias i alias {} ;#}
+ interp alias i alias {} test this
+ i eval alias
+} this
+
# cleanup
foreach i [interp slaves] {
interp delete $i