summaryrefslogtreecommitdiffstats
path: root/generic/tclBasic.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-08-14 04:13:21 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-08-14 04:13:21 (GMT)
commit9d1f38c3e3690b0f7b473375d4fe633656c630a4 (patch)
tree9edd34021f1b308765b2ac9f122e914a0c1d20f9 /generic/tclBasic.c
parent33647e79c82706ff257c5d6bad26438a27f90354 (diff)
downloadtcl-9d1f38c3e3690b0f7b473375d4fe633656c630a4.zip
tcl-9d1f38c3e3690b0f7b473375d4fe633656c630a4.tar.gz
tcl-9d1f38c3e3690b0f7b473375d4fe633656c630a4.tar.bz2
Only schedule leave traces if enter traces complete successfully.
This avoids a memleak, and opens a data slot, so we can pass objc, objv without the need to copy them into a list value.
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r--generic/tclBasic.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index b6c6f38..f852b44 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -4665,13 +4665,13 @@ TEOV_RunEnterTraces(
*cmdPtrPtr = cmdPtr;
}
- if (cmdPtr) {
+ if (cmdPtr && (traceCode == TCL_OK)) {
/*
* Command was found: push a record to schedule the leave traces.
*/
- TclNRAddCallback(interp, TEOV_RunLeaveTraces, INT2PTR(traceCode),
- commandPtr, cmdPtr, Tcl_NewListObj(objc, objv));
+ TclNRAddCallback(interp, TEOV_RunLeaveTraces, INT2PTR(objc),
+ commandPtr, cmdPtr, objv);
cmdPtr->refCount++;
} else {
Tcl_DecrRefCount(commandPtr);
@@ -4686,19 +4686,18 @@ TEOV_RunLeaveTraces(
int result)
{
Interp *iPtr = (Interp *) interp;
- const char *command;
- int length, objc;
- Tcl_Obj **objv;
- int traceCode = PTR2INT(data[0]);
+ int traceCode = TCL_OK;
+ int objc = PTR2INT(data[0]);
Tcl_Obj *commandPtr = data[1];
Command *cmdPtr = data[2];
- Tcl_Obj *wordsPtr = data[3];
+ Tcl_Obj **objv = data[3];
- command = Tcl_GetStringFromObj(commandPtr, &length);
- Tcl_ListObjGetElements(NULL, wordsPtr, &objc, &objv);
if (!(cmdPtr->flags & CMD_IS_DELETED)) {
- if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && traceCode == TCL_OK){
+ int length;
+ const char *command = Tcl_GetStringFromObj(commandPtr, &length);
+
+ if (cmdPtr->flags & CMD_HAS_EXEC_TRACES){
traceCode = TclCheckExecutionTraces(interp, command, length,
cmdPtr, result, TCL_TRACE_LEAVE_EXEC, objc, objv);
}
@@ -4708,7 +4707,6 @@ TEOV_RunLeaveTraces(
}
}
Tcl_DecrRefCount(commandPtr);
- Tcl_DecrRefCount(wordsPtr);
/*
* As cmdPtr is set, TclNRRunCallbacks is about to reduce the numlevels.