summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2020-07-15 20:06:07 (GMT)
committersebres <sebres@users.sourceforge.net>2020-07-15 20:06:07 (GMT)
commit439f72dad506c9f5143db634365aab3375b8c532 (patch)
treef2d392f06ca8830cdc213ec86cc7de98ce0fb358 /generic/tclExecute.c
parent1e3b6b37d1734027a4d8cb19ba379a0b676eaffe (diff)
downloadtcl-439f72dad506c9f5143db634365aab3375b8c532.zip
tcl-439f72dad506c9f5143db634365aab3375b8c532.tar.gz
tcl-439f72dad506c9f5143db634365aab3375b8c532.tar.bz2
closes [3c6e47363e]: missing de-duplication mechanism for nested TEBC starting from scratch (e. g. nested compiled blocks enclosed in parent cycle), so reset interp's result to avoid possible duplications of large objects by first commands like lappend, append, etc
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 76feb79..dd82f95 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -2214,6 +2214,22 @@ TEBCresume(
if (!pc) {
/* bytecode is starting from scratch */
pc = codePtr->codeStart;
+
+ /*
+ * Reset the interp's result to avoid possible duplications of large
+ * objects [3c6e47363e], [781585], [804681], This can happen by start
+ * also in nested compiled blocks (enclosed in parent cycle).
+ * See else branch below for opposite handling by continuation/resume.
+ */
+
+ objPtr = iPtr->objResultPtr;
+ if (objPtr->refCount > 1) {
+ TclDecrRefCount(objPtr);
+ TclNewObj(objPtr);
+ Tcl_IncrRefCount(objPtr);
+ iPtr->objResultPtr = objPtr;
+ }
+
goto cleanup0;
} else {
/* resume from invocation */
@@ -2253,7 +2269,7 @@ TEBCresume(
objc, cmdNameBuf), Tcl_GetObjResult(interp));
/*
- * Reset the interp's result to avoid possible duplications of large
+ * Obtain and reset interp's result to avoid possible duplications of
* objects [Bug 781585]. We do not call Tcl_ResetResult to avoid any
* side effects caused by the resetting of errorInfo and errorCode
* [Bug 804681], which are not needed here. We chose instead to