summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2003-08-05 15:59:15 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2003-08-05 15:59:15 (GMT)
commitd2b201f4eff207fdee59c2c28ecb0d31cb28fb43 (patch)
treebc69650a34f645dc70ff1ef7a9aab5864ed17f76 /generic
parent73d0a6fc2d48ac4bea1e1ed96781bdd37c33647f (diff)
downloadtcl-d2b201f4eff207fdee59c2c28ecb0d31cb28fb43.zip
tcl-d2b201f4eff207fdee59c2c28ecb0d31cb28fb43.tar.gz
tcl-d2b201f4eff207fdee59c2c28ecb0d31cb28fb43.tar.bz2
* generic/tclexecute.c (INST_INVOKE, INST_EVAL, INST_PUSH_RESULT):
added a Tcl_ResetResult(interp) at each point where the interp's result is pushed onto the stack, to avoid keeping an extra reference that may cause costly Tcl_Obj duplication [Bug 781585] Detected by Franco Violi, analyzed by Peter Spjuth and Donal Fellows.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 06cd7fa..fcf2dae 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.104 2003/06/27 21:33:05 dgp Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.105 2003/08/05 15:59:15 msofer Exp $
*/
#include "tclInt.h"
@@ -1428,7 +1428,16 @@ TclExecuteByteCode(interp, codePtr)
objc, cmdNameBuf), Tcl_GetObjResult(interp));
objResultPtr = Tcl_GetObjResult(interp);
- NEXT_INST_V(pcAdjustment, opnd, 1);
+
+ /*
+ * Reset the interp's result to avoid possible duplications
+ * of large objects [Bug 781585]; be careful to increase its
+ * refCount before resetting the result.
+ */
+
+ Tcl_IncrRefCount(objResultPtr);
+ Tcl_ResetResult(interp);
+ NEXT_INST_V(pcAdjustment, opnd, -1);
} else {
cleanup = opnd;
goto processExceptionReturn;
@@ -1454,7 +1463,16 @@ TclExecuteByteCode(interp, codePtr)
objResultPtr = Tcl_GetObjResult(interp);
TRACE_WITH_OBJ(("\"%.30s\" => ", O2S(objPtr)),
Tcl_GetObjResult(interp));
- NEXT_INST_F(1, 1, 1);
+
+ /*
+ * Reset the interp's result to avoid possible duplications
+ * of large objects [Bug 781585]; be careful to increase its
+ * refCount before resetting the result.
+ */
+
+ Tcl_IncrRefCount(objResultPtr);
+ Tcl_ResetResult(interp);
+ NEXT_INST_F(1, 1, -1);
} else {
cleanup = 1;
goto processExceptionReturn;
@@ -3995,7 +4013,15 @@ TclExecuteByteCode(interp, codePtr)
case INST_PUSH_RESULT:
objResultPtr = Tcl_GetObjResult(interp);
TRACE_WITH_OBJ(("=> "), Tcl_GetObjResult(interp));
- NEXT_INST_F(1, 0, 1);
+ /*
+ * Reset the interp's result to avoid possible duplications
+ * of large objects [Bug 781585]; be careful to increase its
+ * refCount before resetting the result.
+ */
+
+ Tcl_IncrRefCount(objResultPtr);
+ Tcl_ResetResult(interp);
+ NEXT_INST_F(1, 0, -1);
case INST_PUSH_RETURN_CODE:
objResultPtr = Tcl_NewLongObj(result);