diff options
author | andreas_kupries <akupries@shaw.ca> | 2009-12-10 19:13:14 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2009-12-10 19:13:14 (GMT) |
commit | abf1be61be7027de251f907e3cdb80351046d6c2 (patch) | |
tree | 579abe979c803fdee93843052a5b6e44f6bfcc45 /generic/tclObj.c | |
parent | 2ebc72a9519a681d7fdd09c8e17ceb49bbdd521e (diff) | |
download | tcl-abf1be61be7027de251f907e3cdb80351046d6c2.zip tcl-abf1be61be7027de251f907e3cdb80351046d6c2.tar.gz tcl-abf1be61be7027de251f907e3cdb80351046d6c2.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.
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 26 |
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)); |