diff options
| author | dgp@users.sourceforge.net <dgp> | 2013-08-07 14:41:46 (GMT) |
|---|---|---|
| committer | dgp@users.sourceforge.net <dgp> | 2013-08-07 14:41:46 (GMT) |
| commit | 4ea86de7fcfd5ed32f00958dee6d33663bc2aff8 (patch) | |
| tree | 8228756a03ab4d71d104523963b6399dc83c4bc5 | |
| parent | e70f297ce2c1f07281c49017ef5203854b8b91dc (diff) | |
| download | tcl-4ea86de7fcfd5ed32f00958dee6d33663bc2aff8.zip tcl-4ea86de7fcfd5ed32f00958dee6d33663bc2aff8.tar.gz tcl-4ea86de7fcfd5ed32f00958dee6d33663bc2aff8.tar.bz2 | |
Replace potentially memleak creating safety check of a "cannot happen"
condition with an assertion.
| -rw-r--r-- | generic/tclParse.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c index 6723d39..c5cb1d1 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -13,6 +13,7 @@ * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#include <assert.h> #include "tclInt.h" #include "tclParse.h" @@ -1578,16 +1579,13 @@ Tcl_ParseVar( * At this point we should have an object containing the value of a * variable. Just return the string from that object. * - * This should have returned the object for the user to manage, but - * instead we have some weak reference to the string value in the object, - * which is why we make sure the object exists after resetting the result. - * This isn't ideal, but it's the best we can do with the current - * documented interface. -- hobbs + * Since TclSubstTokens above returned TCL_OK, we know that objPtr + * is shared. It is in both the interp result and the value of the + * variable. Returning the string relies on that to be true. */ - if (!Tcl_IsShared(objPtr)) { - Tcl_IncrRefCount(objPtr); - } + assert( Tcl_IsShared(objPtr) ); + Tcl_ResetResult(interp); return TclGetString(objPtr); } |
