summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--generic/tclObj.c26
2 files changed, 29 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 7eaa42e..08e49d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-12-10 Andreas Kupries <andreask@activestate.com>
+
+ * 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.
+
2009-12-09 Andreas Kupries <andreask@activestate.com>
* library/safe.tcl: Backport of the streamlined safe base from
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));