summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2001-11-30 14:59:01 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2001-11-30 14:59:01 (GMT)
commitcd2cbdf213a606bdd6c92e568f454a388799dc37 (patch)
treec0f8cafc1d7a02e7d4de0a7a3651a71b19ef4c22
parent9e3fea651cf621b8c1fa4e18d8004addf67d857d (diff)
downloadtcl-cd2cbdf213a606bdd6c92e568f454a388799dc37.zip
tcl-cd2cbdf213a606bdd6c92e568f454a388799dc37.tar.gz
tcl-cd2cbdf213a606bdd6c92e568f454a388799dc37.tar.bz2
Tcl_Preserve'ing VarTrace structures to avoid memory corruption [Bug: 484334]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclVar.c20
2 files changed, 19 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fd01001..ae56907 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-11-30 Miguel Sofer <msofer@users.sourceforge.net>
+
+ * generic/tclVar.c: Tcl_Preserve'ing VarTrace structures to avoid
+ memory corruption. Patch for [Bug: 484334] provided by Don Porter
+
2001-11-29 Miguel Sofer <msofer@users.sourceforge.net>
* tests/namespace.test: modified namespace-41.2, added 41.3
diff --git a/generic/tclVar.c b/generic/tclVar.c
index 31437e7..4e2dc2e 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.41 2001/11/19 14:35:54 dkf Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.42 2001/11/30 14:59:01 msofer Exp $
*/
#include "tclInt.h"
@@ -2374,7 +2374,7 @@ Tcl_UnsetVar2(interp, part1, part2, flags)
while (dummyVar.tracePtr != NULL) {
VarTrace *tracePtr = dummyVar.tracePtr;
dummyVar.tracePtr = tracePtr->nextPtr;
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
activePtr = activePtr->nextPtr) {
@@ -2695,7 +2695,7 @@ Tcl_UntraceVar2(interp, part1, part2, flags, proc, clientData)
} else {
prevPtr->nextPtr = tracePtr->nextPtr;
}
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
/*
* If this is the last trace on the variable, and the variable is
@@ -4495,6 +4495,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
result = NULL;
active.nextPtr = iPtr->activeTracePtr;
iPtr->activeTracePtr = &active;
+ Tcl_Preserve((ClientData) iPtr);
if (arrayPtr != NULL && !(arrayPtr->flags & VAR_TRACE_ACTIVE)) {
arrayPtr->refCount++;
active.varPtr = arrayPtr;
@@ -4504,6 +4505,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
if (!(tracePtr->flags & flags)) {
continue;
}
+ Tcl_Preserve((ClientData) tracePtr);
result = (*tracePtr->traceProc)(tracePtr->clientData,
(Tcl_Interp *) iPtr, part1, part2, flags);
if (result != NULL) {
@@ -4517,9 +4519,11 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
}
result = NULL;
} else {
+ Tcl_Release((ClientData) tracePtr);
goto done;
}
}
+ Tcl_Release((ClientData) tracePtr);
}
}
@@ -4537,6 +4541,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
if (!(tracePtr->flags & flags)) {
continue;
}
+ Tcl_Preserve((ClientData) tracePtr);
result = (*tracePtr->traceProc)(tracePtr->clientData,
(Tcl_Interp *) iPtr, part1, part2, flags);
if (result != NULL) {
@@ -4550,9 +4555,11 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
}
result = NULL;
} else {
+ Tcl_Release((ClientData) tracePtr);
goto done;
}
}
+ Tcl_Release((ClientData) tracePtr);
}
/*
@@ -4570,6 +4577,7 @@ CallTraces(iPtr, arrayPtr, varPtr, part1, part2, flags, resultTypePtr)
varPtr->flags &= ~VAR_TRACE_ACTIVE;
varPtr->refCount--;
iPtr->activeTracePtr = active.nextPtr;
+ Tcl_Release((ClientData) iPtr);
return result;
}
@@ -4894,7 +4902,7 @@ TclDeleteVars(iPtr, tablePtr)
while (varPtr->tracePtr != NULL) {
VarTrace *tracePtr = varPtr->tracePtr;
varPtr->tracePtr = tracePtr->nextPtr;
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
activePtr = activePtr->nextPtr) {
@@ -5028,7 +5036,7 @@ TclDeleteCompiledLocalVars(iPtr, framePtr)
while (varPtr->tracePtr != NULL) {
VarTrace *tracePtr = varPtr->tracePtr;
varPtr->tracePtr = tracePtr->nextPtr;
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr, TCL_DYNAMIC);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
activePtr = activePtr->nextPtr) {
@@ -5127,7 +5135,7 @@ DeleteArray(iPtr, arrayName, varPtr, flags)
while (elPtr->tracePtr != NULL) {
VarTrace *tracePtr = elPtr->tracePtr;
elPtr->tracePtr = tracePtr->nextPtr;
- ckfree((char *) tracePtr);
+ Tcl_EventuallyFree((ClientData) tracePtr,TCL_DYNAMIC);
}
for (activePtr = iPtr->activeTracePtr; activePtr != NULL;
activePtr = activePtr->nextPtr) {