summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclZlib.c4
-rw-r--r--tests/zlib.test12
2 files changed, 14 insertions, 2 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index e5a5946..82486d2 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -1204,10 +1204,10 @@ Tcl_ZlibStreamPut(
zshPtr->stream.avail_in = size;
/*
- * Must not do a zero-length compress. [Bug 25842c161]
+ * Must not do a zero-length compress unless finalizing. [Bug 25842c161]
*/
- if (size == 0) {
+ if (size == 0 && flush != Z_FINISH) {
return TCL_OK;
}
diff --git a/tests/zlib.test b/tests/zlib.test
index ae8742b..3ee7a45 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -157,6 +157,18 @@ test zlib-7.8 {zlib stream: Bug b26e38a3e4} -constraints zlib -setup {
catch {$strm close}
unset -nocomplain randdata data
} -result {120185 18003000}
+test zlib-7.9 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set z1 [zlib stream gzip]
+ set z2 [zlib stream gzip]
+} -body {
+ $z1 put ABCDEedbca..
+ $z1 finalize
+ $z2 put -finalize ABCDEedbca..
+ expr {[$z1 get] eq [$z2 get]}
+} -cleanup {
+ $z1 close
+ $z2 close
+} -result 1
test zlib-8.1 {zlib transformation} -constraints zlib -setup {
set file [makeFile {} test.gz]