summaryrefslogtreecommitdiffstats
path: root/generic/tclObj.c
diff options
context:
space:
mode:
authorandreas_kupries <andreas_kupries@noemail.net>2009-12-10 19:13:13 (GMT)
committerandreas_kupries <andreas_kupries@noemail.net>2009-12-10 19:13:13 (GMT)
commitcbee144cf95bbb33fb1d3e3f487907b5cbac2a31 (patch)
tree579abe979c803fdee93843052a5b6e44f6bfcc45 /generic/tclObj.c
parentfd09331f38b0764a9fbaa22a35d85a4688738369 (diff)
downloadtcl-cbee144cf95bbb33fb1d3e3f487907b5cbac2a31.zip
tcl-cbee144cf95bbb33fb1d3e3f487907b5cbac2a31.tar.gz
tcl-cbee144cf95bbb33fb1d3e3f487907b5cbac2a31.tar.bz2
* generic/tclObj.c (TclContinuationsEnter): [Bug 2895323]: Updated
comments to describe when the function can be entered for the same Tcl_Obj* multiple times. This is a continuation of the 2009-11-10 entry where a memory leak was plugged, but where not sure if that was just a band-aid to paper over some other error. It isn't, this is a legal situation. FossilOrigin-Name: 60381f421b3c15abb25aa19cde6591e263d33bb4
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r--generic/tclObj.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c
index 7a37fd3..56db483 100644
--- a/generic/tclObj.c
+++ b/generic/tclObj.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: tclObj.c,v 1.139.2.6 2009/11/10 16:46:16 dgp Exp $
+ * RCS: @(#) $Id: tclObj.c,v 1.139.2.7 2009/12/10 19:13:15 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -574,12 +574,26 @@ TclContinuationsEnter(Tcl_Obj* objPtr,
ContLineLoc* clLocPtr =
(ContLineLoc*) ckalloc (sizeof(ContLineLoc) + num*sizeof(int));
- if (newEntry == 0) {
+ if (!newEntry) {
/*
- * Somehow we're entering ContLineLoc data for the same value more
- * than one time. Not sure whether that's expected, or a sign of
- * trouble, but at a minimum, we should take care not to leak the
- * old entry.
+ * We're entering ContLineLoc data for the same value more than one
+ * time. Taking care not to leak the old entry.
+ *
+ * This can happen when literals in a proc body are shared. See for
+ * example test info-30.19 where the action (code) for all branches of
+ * the switch command is identical, mapping them all to the same
+ * literal. An interesting result of this is that the number and
+ * locations (offset) of invisible continuation lines in the literal
+ * are the same for all occurences.
+ *
+ * Note that while reusing the existing entry is possible it requires
+ * the same actions as for a new entry because we have to copy the
+ * incoming num/loc data even so. Because we are called from
+ * TclContinuationsEnterDerived for this case, which modified the
+ * stored locations (Rebased to the proper relative offset). Just
+ * returning the stored entry and data would rebase them a second
+ * time, or more, hosing the data. It is easier to simply replace, as
+ * we are doing.
*/
ckfree((char *) Tcl_GetHashValue(hPtr));