summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2013-08-07 14:41:46 (GMT)
committerdgp <dgp@users.sourceforge.net>2013-08-07 14:41:46 (GMT)
commit9923dc2908c517db587b6cbb398398ab3e45ec16 (patch)
tree8228756a03ab4d71d104523963b6399dc83c4bc5 /generic
parent47750cf97411377b0562db3816394c12707d8590 (diff)
downloadtcl-9923dc2908c517db587b6cbb398398ab3e45ec16.zip
tcl-9923dc2908c517db587b6cbb398398ab3e45ec16.tar.gz
tcl-9923dc2908c517db587b6cbb398398ab3e45ec16.tar.bz2
Replace potentially memleak creating safety check of a "cannot happen"
condition with an assertion.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclParse.c14
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);
}