diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-03-22 14:15:06 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2013-03-22 14:15:06 (GMT) |
commit | ae6d91316afca4d7295521163352757b570d0e85 (patch) | |
tree | 5b77771e69c55c2bb651a5ccdba2337103cdffad /generic/tclObj.c | |
parent | c5e46efb954d7d3ec9a1594489918053bde2e758 (diff) | |
parent | 1aba207fe781bcbb05472aadff385d3a7bc0b819 (diff) | |
download | tcl-ae6d91316afca4d7295521163352757b570d0e85.zip tcl-ae6d91316afca4d7295521163352757b570d0e85.tar.gz tcl-ae6d91316afca4d7295521163352757b570d0e85.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index b62c088..2cbc6ed 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -1333,9 +1333,21 @@ TclFreeObj( ObjInitDeletionContext(context); + /* + * Check for a double free of the same value. This is slightly tricky + * because it is customary to free a Tcl_Obj when its refcount falls + * either from 1 to 0, or from 0 to -1. Falling from -1 to -2, though, + * and so on, is always a sign of a botch in the caller. + */ if (objPtr->refCount < -1) { Tcl_Panic("Reference count for %p was negative", objPtr); } + /* + * Now, in case we just approved drop from 1 to 0 as acceptable, make + * sure we do not accept a second free when falling from 0 to -1. + * Skip that possibility so any double free will trigger the panic. + */ + objPtr->refCount = -1; /* * Invalidate the string rep first so we can use the bytes value for our |