summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2002-04-12 06:28:33 (GMT)
committerhobbs <hobbs>2002-04-12 06:28:33 (GMT)
commita8f0bfd4bf052b0ff93b876f5aa974b8108a3b22 (patch)
treeeead731801d4b47a19302de3f1190323d8dc907e /generic
parent675c95f0328978013209e9b24d23e38894e49a0d (diff)
downloadtcl-a8f0bfd4bf052b0ff93b876f5aa974b8108a3b22.zip
tcl-a8f0bfd4bf052b0ff93b876f5aa974b8108a3b22.tar.gz
tcl-a8f0bfd4bf052b0ff93b876f5aa974b8108a3b22.tar.bz2
* generic/tclParse.c (Tcl_ParseVar): conditionally incr obj
refcount to prevent possible mem leak.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclParse.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c
index d5aaa90..19aa324 100644
--- a/generic/tclParse.c
+++ b/generic/tclParse.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclParse.c,v 1.19 2002/01/17 02:43:19 dgp Exp $
+ * RCS: @(#) $Id: tclParse.c,v 1.20 2002/04/12 06:28:33 hobbs Exp $
*/
#include "tclInt.h"
@@ -1021,9 +1021,17 @@ Tcl_ParseVar(interp, string, termPtr)
/*
* 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
*/
- Tcl_IncrRefCount(objPtr);
+ if (!Tcl_IsShared(objPtr)) {
+ Tcl_IncrRefCount(objPtr);
+ }
Tcl_ResetResult(interp);
return TclGetString(objPtr);
}