summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2001-11-21 17:17:17 (GMT)
committerdgp <dgp@users.sourceforge.net>2001-11-21 17:17:17 (GMT)
commitce8d99c1e94271f0d1f544785308d77954153eeb (patch)
treed77fa27729e178cf36c9fbf4c5d395f519ca552d
parentff6d644685d5d3413b6ff4287c80cfd30f2693de (diff)
downloadtcl-ce8d99c1e94271f0d1f544785308d77954153eeb.zip
tcl-ce8d99c1e94271f0d1f544785308d77954153eeb.tar.gz
tcl-ce8d99c1e94271f0d1f544785308d77954153eeb.tar.bz2
* generic/tclBasic.c (Tcl_DeleteCommandFromToken,CallCommandTraces):
* generic/tclCmdMZ>c (Tcl_UntraceCommand): Added Tcl_Preserve and Tcl_Release calls to prevent deletion of CommandTrace structures until all callers are done using them, preventing memory corruption. [Bug 453805]
-rw-r--r--ChangeLog8
-rw-r--r--generic/tclBasic.c8
-rw-r--r--generic/tclCmdMZ.c4
3 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 011badd..33e3858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-11-21 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclBasic.c (Tcl_DeleteCommandFromToken,CallCommandTraces):
+ * generic/tclCmdMZ>c (Tcl_UntraceCommand): Added Tcl_Preserve and
+ Tcl_Release calls to prevent deletion of CommandTrace structures
+ until all callers are done using them, preventing memory corruption.
+ [Bug 453805]
+
2001-11-20 Kevin B. Kenny <kennykb@users.sourceforge.net>
* doc/GetTime.3 (Tcl_GetTime):
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index a9f8276..ab9e1f0 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.41 2001/11/20 22:47:58 msofer Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.42 2001/11/21 17:17:17 dgp Exp $
*/
#include "tclInt.h"
@@ -2323,7 +2323,7 @@ Tcl_DeleteCommandFromToken(interp, cmd)
tracePtr = cmdPtr->tracePtr;
while (tracePtr != NULL) {
CommandTrace *nextPtr = tracePtr->nextPtr;
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
tracePtr = nextPtr;
}
cmdPtr->tracePtr = NULL;
@@ -2458,6 +2458,7 @@ CallCommandTraces(iPtr, cmdPtr, oldName, newName, flags)
iPtr->activeCmdTracePtr = &active;
active.cmdPtr = cmdPtr;
+ Tcl_Preserve((ClientData) iPtr);
for (tracePtr = cmdPtr->tracePtr; tracePtr != NULL;
tracePtr = active.nextTracePtr) {
active.nextTracePtr = tracePtr->nextPtr;
@@ -2469,9 +2470,11 @@ CallCommandTraces(iPtr, cmdPtr, oldName, newName, flags)
oldName = Tcl_GetCommandName((Tcl_Interp *) iPtr,
(Tcl_Command) cmdPtr);
}
+ Tcl_Preserve((ClientData) tracePtr);
(*tracePtr->traceProc)(tracePtr->clientData,
(Tcl_Interp *) iPtr, oldName, newName, flags);
cmdPtr->flags &= ~tracePtr->flags;
+ Tcl_Release((ClientData) tracePtr);
}
/*
@@ -2482,6 +2485,7 @@ CallCommandTraces(iPtr, cmdPtr, oldName, newName, flags)
cmdPtr->flags &= ~CMD_TRACE_ACTIVE;
cmdPtr->refCount--;
iPtr->activeCmdTracePtr = active.nextPtr;
+ Tcl_Release((ClientData) iPtr);
return result;
}
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 34af105..22634d5 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdMZ.c,v 1.50 2001/11/21 02:36:20 hobbs Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.51 2001/11/21 17:17:17 dgp Exp $
*/
#include "tclInt.h"
@@ -3472,7 +3472,7 @@ Tcl_UntraceCommand(interp, cmdName, flags, proc, clientData)
} else {
prevPtr->nextPtr = tracePtr->nextPtr;
}
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
}
/*