summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--generic/tclExecute.c34
2 files changed, 39 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 4069f46..79b722f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-08-05 Miguel Sofer <msofer@users.sf.net>
+
+ * 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.
+
2003-07-24 Reinhard Max <max@suse.de>
* library/package.tcl: Fixed a typo that broke pkg_mkIndex -verbose.
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 578be7e..15a5c7a 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.94.2.3 2003/06/10 19:58:35 msofer Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.94.2.4 2003/08/05 16:19:54 msofer Exp $
*/
#include "tclInt.h"
@@ -1425,7 +1425,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;
@@ -1451,7 +1460,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;
@@ -3931,7 +3949,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);