summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2010-02-08 13:21:41 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2010-02-08 13:21:41 (GMT)
commiteb39e6f02a3eabc00c00bec84cb9c83f60f6d828 (patch)
treef662b09530809cd10e7acbf85ad31ceec110dc85
parentbaafc87e3c7fe20ed29437a7e7b44f9f06f4e974 (diff)
downloadtcl-eb39e6f02a3eabc00c00bec84cb9c83f60f6d828.zip
tcl-eb39e6f02a3eabc00c00bec84cb9c83f60f6d828.tar.gz
tcl-eb39e6f02a3eabc00c00bec84cb9c83f60f6d828.tar.bz2
[Bug 2947783]: Ensure that result is an unshared object before appending to it.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclZlib.c20
2 files changed, 26 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ce3e2dc..e82b91a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-02-08 Donal K. Fellows <dkf@users.sf.net>
+
+ * generic/tclZlib.c (Tcl_ZlibDeflate, Tcl_ZlibInflate): [Bug 2947783]:
+ Make sure that the result is an unshared object before appending to it
+ so that nothing crashes if it is shared (use in Tcl code was not
+ affected by this, but use from C was an issue).
+
2010-02-06 Donal K. Fellows <dkf@users.sf.net>
* generic/tclHash.c (HashStringKey): Replace Tcl's crusty old hash
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 2ae12c0..f43f704 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.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: tclZlib.c,v 1.32 2009/11/18 21:59:51 nijtmans Exp $
+ * RCS: @(#) $Id: tclZlib.c,v 1.33 2010/02/08 13:21:42 dkf Exp $
*/
#include "tclInt.h"
@@ -1316,6 +1316,15 @@ Tcl_ZlibDeflate(
obj = Tcl_GetObjResult(interp);
/*
+ * Make sure that the result is an unshared object. [Bug 2947783]
+ */
+
+ if (Tcl_IsShared(obj)) {
+ obj = Tcl_DuplicateObj(obj);
+ Tcl_SetObjResult(interp, obj);
+ }
+
+ /*
* Compressed format is specified by the wbits parameter. See zlib.h for
* details.
*/
@@ -1469,6 +1478,15 @@ Tcl_ZlibInflate(
obj = Tcl_GetObjResult(interp);
/*
+ * Make sure that the result is an unshared object. [Bug 2947783]
+ */
+
+ if (Tcl_IsShared(obj)) {
+ obj = Tcl_DuplicateObj(obj);
+ Tcl_SetObjResult(interp, obj);
+ }
+
+ /*
* Compressed format is specified by the wbits parameter. See zlib.h for
* details.
*/