summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2017-04-25 16:33:30 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2017-04-25 16:33:30 (GMT)
commit5ea5f8427a047cb62fa129dd18ae604af11dede9 (patch)
treeb26b4b0eddb244ecdeca266081b4829ed1b466fe
parentbf7b67a97a09ae4c8b75901048ccdffb0c6bbe83 (diff)
downloadtcl-mistkae.zip
tcl-mistkae.tar.gz
tcl-mistkae.tar.bz2
[50750c735a] Possible fix for uninit memory handling issue in [zlib].mistkae
-rw-r--r--generic/tclZlib.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 82486d2..37a1c09 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -3118,25 +3118,15 @@ ZlibTransformOutput(
do {
e = Deflate(&cd->outStream, cd->outBuffer, cd->outAllocated,
Z_NO_FLUSH, &produced);
+ if (e != Z_OK || produced == 0) {
+ break;
+ }
- if ((e == Z_OK && produced > 0) || e == Z_BUF_ERROR) {
- /*
- * deflate() indicates that it is out of space by returning
- * Z_BUF_ERROR *or* by simply returning Z_OK with no remaining
- * space; in either case, we must write the whole buffer out and
- * retry to compress what is left.
- */
-
- if (e == Z_BUF_ERROR) {
- produced = cd->outAllocated;
- e = Z_OK;
- }
- if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) {
- *errorCodePtr = Tcl_GetErrno();
- return -1;
- }
+ if (Tcl_WriteRaw(cd->parent, cd->outBuffer, produced) < 0) {
+ *errorCodePtr = Tcl_GetErrno();
+ return -1;
}
- } while (e == Z_OK && produced > 0 && cd->outStream.avail_in > 0);
+ } while (cd->outStream.avail_in > 0);
if (e == Z_OK) {
return toWrite - cd->outStream.avail_in;