summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2017-02-26 15:33:04 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2017-02-26 15:33:04 (GMT)
commitc8c30d6dacd71f453e3bfb95c66cbee3df3468e0 (patch)
treeef78c2d1c6d9e609ffd56e60c2882a85d154cd74
parent3b5e7e9792b9b34111146557a3353756711b8133 (diff)
parent1609a65c29afebbca87366c03e2aed20468ca7e5 (diff)
downloadtcl-c8c30d6dacd71f453e3bfb95c66cbee3df3468e0.zip
tcl-c8c30d6dacd71f453e3bfb95c66cbee3df3468e0.tar.gz
tcl-c8c30d6dacd71f453e3bfb95c66cbee3df3468e0.tar.bz2
[25842c161f] Ensure that finalization of a zlib stream works.
-rw-r--r--generic/tclZlib.c4
-rw-r--r--tests/zlib.test42
2 files changed, 44 insertions, 2 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index c231f44..96b8318 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..1e69745 100644
--- a/tests/zlib.test
+++ b/tests/zlib.test
@@ -157,6 +157,48 @@ 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
+ zlib gunzip [$z1 get]
+} -cleanup {
+ $z1 close
+} -result ABCDEedbca..
+test zlib-7.10 {zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set z2 [zlib stream gzip]
+} -body {
+ $z2 put -finalize ABCDEedbca..
+ zlib gunzip [$z2 get]
+} -cleanup {
+ $z2 close
+} -result ABCDEedbca..
+test zlib-7.11 {zlib stream put -finalize (bug 25842c161)} -constraints zlib -setup {
+ set c [zlib stream gzip]
+ set d [zlib stream gunzip]
+} -body {
+ $c put abcdeEDCBA..
+ $c finalize
+ $d put [$c get]
+ $d finalize
+ $d get
+} -cleanup {
+ $c close
+ $d close
+} -result abcdeEDCBA..
+test zlib-7.12 {zlib stream put; zlib stream finalize (bug 25842c161)} -constraints zlib -setup {
+ set c [zlib stream gzip]
+ set d [zlib stream gunzip]
+} -body {
+ $c put -finalize abcdeEDCBA..
+ $d put -finalize [$c get]
+ $d get
+} -cleanup {
+ $c close
+ $d close
+} -result abcdeEDCBA..
test zlib-8.1 {zlib transformation} -constraints zlib -setup {
set file [makeFile {} test.gz]