diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-28 08:00:51 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-04-28 08:00:51 (GMT) |
| commit | 2f5a766c71b1796f47a58123f17c3242b607feca (patch) | |
| tree | 6e85f7dd2b98f0c060086540c153617c8b70ae9d /generic/tclZlib.c | |
| parent | ea1a2f3fbf4607b58ceffe3606b2d2e7e59e609f (diff) | |
| parent | 2bf6ae09b3ac48095177c0f52735fb9bfa10f164 (diff) | |
| download | tcl-2f5a766c71b1796f47a58123f17c3242b607feca.zip tcl-2f5a766c71b1796f47a58123f17c3242b607feca.tar.gz tcl-2f5a766c71b1796f47a58123f17c3242b607feca.tar.bz2 | |
merge core-8-6-branch
Diffstat (limited to 'generic/tclZlib.c')
| -rw-r--r-- | generic/tclZlib.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c index 82486d2..fc20d7e 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -3113,30 +3113,28 @@ ZlibTransformOutput( errorCodePtr); } + /* + * No zero-length writes. Flushes must be explicit. + */ + + if (toWrite == 0) { + return 0; + } + cd->outStream.next_in = (Bytef *) buf; cd->outStream.avail_in = toWrite; - do { + while (cd->outStream.avail_in > 0) { 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); + } if (e == Z_OK) { return toWrite - cd->outStream.avail_in; |
