summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-03-30 14:16:11 (GMT)
committernijtmans <nijtmans>2010-03-30 14:16:11 (GMT)
commitdfeca193ef249620df45325196b9ee70e984eef6 (patch)
treeec5f44553fa37e78955967919f4276f7788d38d0
parent12a044c1cb8a5053df967f4a9fa8f90f1cf3388e (diff)
downloadtcl-dfeca193ef249620df45325196b9ee70e984eef6.zip
tcl-dfeca193ef249620df45325196b9ee70e984eef6.tar.gz
tcl-dfeca193ef249620df45325196b9ee70e984eef6.tar.bz2
[Bug 2979399] uninitialized value troubles
-rw-r--r--ChangeLog1
-rw-r--r--generic/tclZlib.c33
2 files changed, 6 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index b14a9b9..b95dd0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* generic/tclIndexObj: [FRQ 2974744]: share exception codes (ObjType?):
* generic/tclResult.c: further optimization, making use of indexType.
+ * generic/tclZlib.c [Bug 2979399] uninitialized value troubles
2010-03-30 Donal K. Fellows <dkf@users.sf.net>
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index a8d97d4..ea9c996 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.36 2010/03/05 14:34:04 dkf Exp $
+ * RCS: @(#) $Id: tclZlib.c,v 1.37 2010/03/30 14:16:11 nijtmans Exp $
*/
#include "tclInt.h"
@@ -619,20 +619,12 @@ Tcl_ZlibStreamInit(
zshPtr->wbits = wbits;
zshPtr->currentInput = NULL;
zshPtr->streamEnd = 0;
- zshPtr->stream.avail_in = 0;
- zshPtr->stream.next_in = 0;
- zshPtr->stream.zalloc = 0;
- zshPtr->stream.zfree = 0;
- zshPtr->stream.opaque = 0; /* Must be initialized before calling
- * (de|in)flateInit2 */
+ memset(&zshPtr->stream, 0, sizeof(z_stream));
/*
* No output buffer available yet
*/
- zshPtr->stream.avail_out = 0;
- zshPtr->stream.next_out = NULL;
-
if (mode == TCL_ZLIB_STREAM_DEFLATE) {
e = deflateInit2(&zshPtr->stream, level, Z_DEFLATED, wbits,
MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
@@ -852,20 +844,12 @@ Tcl_ZlibStreamReset(
zshPtr->outPos = 0;
zshPtr->streamEnd = 0;
- zshPtr->stream.avail_in = 0;
- zshPtr->stream.next_in = 0;
- zshPtr->stream.zalloc = 0;
- zshPtr->stream.zfree = 0;
- zshPtr->stream.opaque = 0; /* Must be initialized before calling
- * (de|in)flateInit2 */
+ memset(&zshPtr->stream, 0, sizeof(z_stream));
/*
* No output buffer available yet.
*/
- zshPtr->stream.avail_out = 0;
- zshPtr->stream.next_out = NULL;
-
if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) {
e = deflateInit2(&zshPtr->stream, zshPtr->level, Z_DEFLATED,
zshPtr->wbits, MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
@@ -1370,20 +1354,14 @@ Tcl_ZlibDeflate(
*/
inData = Tcl_GetByteArrayFromObj(data, &inLen);
+ memset(&stream, 0, sizeof(z_stream));
stream.avail_in = (uInt) inLen;
stream.next_in = inData;
- stream.zalloc = 0;
- stream.zfree = 0;
- stream.opaque = 0; /* Must be initialized before calling
- * deflateInit2 */
/*
* No output buffer available yet, will alloc after deflateInit2.
*/
- stream.avail_out = 0;
- stream.next_out = NULL;
-
e = deflateInit2(&stream, level, Z_DEFLATED, wbits, MAX_MEM_LEVEL,
Z_DEFAULT_STRATEGY);
if (e != Z_OK) {
@@ -1541,8 +1519,7 @@ Tcl_ZlibInflate(
}
outData = Tcl_SetByteArrayLength(obj, bufferSize);
- stream.zalloc = 0;
- stream.zfree = 0;
+ memset(&stream, 0, sizeof(z_stream));
stream.avail_in = (uInt) inLen+1; /* +1 because zlib can "over-request"
* input (but ignore it!) */
stream.next_in = inData;