summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-03-22 14:15:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-03-22 14:15:06 (GMT)
commitae6d91316afca4d7295521163352757b570d0e85 (patch)
tree5b77771e69c55c2bb651a5ccdba2337103cdffad /generic/tclObj.c
parentc5e46efb954d7d3ec9a1594489918053bde2e758 (diff)
parent1aba207fe781bcbb05472aadff385d3a7bc0b819 (diff)
downloadtcl-ae6d91316afca4d7295521163352757b570d0e85.zip
tcl-ae6d91316afca4d7295521163352757b570d0e85.tar.gz
tcl-ae6d91316afca4d7295521163352757b570d0e85.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r--generic/tclObj.c12
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