diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2003-08-05 16:19:54 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2003-08-05 16:19:54 (GMT) |
commit | bd39475b4139a926053be2ef84d90bb43ac8fe80 (patch) | |
tree | da5e3d7095224648d7b60d548ddf4c25c81d28c2 /generic | |
parent | 8bf71aefeb2605b9a52a0ad26abdcbd2cca773d6 (diff) | |
download | tcl-bd39475b4139a926053be2ef84d90bb43ac8fe80.zip tcl-bd39475b4139a926053be2ef84d90bb43ac8fe80.tar.gz tcl-bd39475b4139a926053be2ef84d90bb43ac8fe80.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.c | 34 |
1 files changed, 30 insertions, 4 deletions
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); |