summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiguel Sofer <miguel.sofer@gmail.com>2007-05-02 00:31:22 (GMT)
committerMiguel Sofer <miguel.sofer@gmail.com>2007-05-02 00:31:22 (GMT)
commite363ced3b4481084d34d11085cfd95b2bf71fe6c (patch)
tree745c0bd4700905a443b114003bb389e582fabe70
parent17b8d2d3e3ac333f60da3b27fc34190d212670dd (diff)
downloadtcl-e363ced3b4481084d34d11085cfd95b2bf71fe6c.zip
tcl-e363ced3b4481084d34d11085cfd95b2bf71fe6c.tar.gz
tcl-e363ced3b4481084d34d11085cfd95b2bf71fe6c.tar.bz2
* generic/tclVar.c (TclPtrSetVar): fixed leak whenever newvaluePtr
had refCount 0 and was used for appending (but not lappending). [Bug 1710710], thanks to mistachkin and kbk.
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclVar.c9
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 52f4119..15f200e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-01 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclVar.c (TclPtrSetVar): fixed leak whenever newvaluePtr
+ had refCount 0 and was used for appending (but not
+ lappending). [Bug 1710710], thanks to mistachkin and kbk.
+
2007-05-01 Kevin B. Kenny <kennykb@acm.org>
* generic/tclIO.c (DeleteChannelTable): Made changes so that
diff --git a/generic/tclVar.c b/generic/tclVar.c
index b4fffb1..2e5f39d 100644
--- a/generic/tclVar.c
+++ b/generic/tclVar.c
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclVar.c,v 1.132 2007/04/23 20:11:10 dgp Exp $
+ * RCS: @(#) $Id: tclVar.c,v 1.133 2007/05/02 00:31:22 msofer Exp $
*/
#include "tclInt.h"
@@ -1649,7 +1649,9 @@ TclPtrSetVar(
}
} else { /* append string */
/*
- * We append newValuePtr's bytes but don't change its ref count.
+ * We append newValuePtr's bytes but don't change its ref count if
+ * non-zero; if newValuePtr has a zero refCount and we are not
+ * using the obj, be sure to free it to avoid a leak.
*/
if (oldValuePtr == NULL) {
@@ -1663,6 +1665,9 @@ TclPtrSetVar(
Tcl_IncrRefCount(oldValuePtr); /* since var is ref */
}
Tcl_AppendObjToObj(oldValuePtr, newValuePtr);
+ if (newValuePtr->refCount == 0) {
+ Tcl_DecrRefCount(newValuePtr);
+ }
}
}
} else if (newValuePtr != oldValuePtr) {