diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2005-10-29 19:16:32 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2005-10-29 19:16:32 (GMT) |
commit | e4937d5509607c42d8ca01d05763d87e8b3e43ce (patch) | |
tree | ad0e330970d975778094123140c4149e361438bb | |
parent | 4b9135a520fdab05e275330093a65b2e1d957438 (diff) | |
download | tcl-e4937d5509607c42d8ca01d05763d87e8b3e43ce.zip tcl-e4937d5509607c42d8ca01d05763d87e8b3e43ce.tar.gz tcl-e4937d5509607c42d8ca01d05763d87e8b3e43ce.tar.bz2 |
* generic/tclTrace.c (TraceVarProc): [Bug 1337229], partial
fix. Insure that a second call with TCL_TRACE_DESTROYED does not
lead to a second call to Tcl_EventuallyFree(). It is still true
that that second call should not happen, so the bug is not
completely fixed.
* tests/trace.test (test-18.3-4): added tests for bugs #1337229
and 1338280.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | generic/tclTrace.c | 10 | ||||
-rw-r--r-- | tests/trace.test | 22 |
3 files changed, 37 insertions, 5 deletions
@@ -1,3 +1,13 @@ +2005-10-29 Miguel Sofer <msofer@users.sf.net> + + * generic/tclCmdMZ.c (TraceVarProc): [Bug 1337229], partial + fix. Insure that a second call with TCL_TRACE_DESTROYED does not + lead to a second call to Tcl_EventuallyFree(). It is still true + that that second call should not happen, so the bug is not + completely fixed. + * tests/trace.test (test-18.3-4): added tests for bugs #1337229 + and 1338280. + 2005-10-23 Vince Darley <vincentdarley@sourceforge.net> * generic/tclFileName.c: fix to memory leak in glob [Bug 1335006] diff --git a/generic/tclTrace.c b/generic/tclTrace.c index 9d7ab86..6976a06 100644 --- a/generic/tclTrace.c +++ b/generic/tclTrace.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclTrace.c,v 1.26 2005/07/23 00:04:31 dkf Exp $ + * RCS: @(#) $Id: tclTrace.c,v 1.27 2005/10/29 19:16:32 msofer Exp $ */ #include "tclInt.h" @@ -1915,7 +1915,7 @@ TraceVarProc(clientData, interp, name1, name2, flags) { TraceVarInfo *tvarPtr = (TraceVarInfo *) clientData; char *result; - int code; + int code, destroy = 0; Tcl_DString cmd; /* @@ -1975,7 +1975,9 @@ TraceVarProc(clientData, interp, name1, name2, flags) * double-free might occur depending on what the eval does. */ - if (flags & TCL_TRACE_DESTROYED) { + if ((flags & TCL_TRACE_DESTROYED) + && !(tvarPtr->flags & TCL_TRACE_DESTROYED)) { + destroy = 1; tvarPtr->flags |= TCL_TRACE_DESTROYED; } code = Tcl_EvalEx(interp, Tcl_DStringValue(&cmd), @@ -1988,7 +1990,7 @@ TraceVarProc(clientData, interp, name1, name2, flags) Tcl_DStringFree(&cmd); } } - if (flags & TCL_TRACE_DESTROYED) { + if (destroy) { if (result != NULL) { register Tcl_Obj *errMsgObj = (Tcl_Obj *) result; diff --git a/tests/trace.test b/tests/trace.test index 6b78fed..93894bf 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: trace.test,v 1.40 2005/07/26 16:24:35 dgp Exp $ +# RCS: @(#) $Id: trace.test,v 1.41 2005/10/29 19:16:32 msofer Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -1160,6 +1160,26 @@ test trace-18.2 {namespace delete / trace vdelete combo} { namespace delete ::foo info exists ::foo::x } 0 +test trace-18.3 {namespace delete / trace vdelete combo, Bug \#1337229} { + namespace eval ::ns {} + trace add variable ::ns::var unset {unset ::ns::var ;#} + namespace delete ::ns +} {} +test trace-18.4 {namespace delete / trace vdelete combo, Bug \#1338280} { + namespace eval ::ref {} + set ::ref::var1 AAA + trace add variable ::ref::var1 unset doTrace + set ::ref::var2 BBB + trace add variable ::ref::var2 {unset} doTrace + proc doTrace {vtraced vidx op} { + global info + append info [catch {set ::$vtraced}][llength [info vars ::ref::*]] + } + set info {} + namespace delete ::ref + rename doTrace {} + set info +} 1110 # Delete arrays when done, so they can be re-used as scalars # elsewhere. |