summaryrefslogtreecommitdiffstats
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)
commit9c15217967a7614ac17d324144b8e39d788b6eef (patch)
tree9edd34021f1b308765b2ac9f122e914a0c1d20f9
parent9d7666659bb7ba5dcf54394bb4c2a555b2f46f7c (diff)
downloadtcl-9c15217967a7614ac17d324144b8e39d788b6eef.zip
tcl-9c15217967a7614ac17d324144b8e39d788b6eef.tar.gz
tcl-9c15217967a7614ac17d324144b8e39d788b6eef.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.
-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.