diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2017-02-26 15:32:11 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2017-02-26 15:32:11 (GMT) |
commit | 1609a65c29afebbca87366c03e2aed20468ca7e5 (patch) | |
tree | e628fbf6702335dd63404aa0fe978dd45d0cfa17 | |
parent | 9b8fe92d1ec10b1010d91d504deab315538cce0e (diff) | |
parent | a9c42fa686ab9236f5218c276ce4bfdc7655ab16 (diff) | |
download | tcl-1609a65c29afebbca87366c03e2aed20468ca7e5.zip tcl-1609a65c29afebbca87366c03e2aed20468ca7e5.tar.gz tcl-1609a65c29afebbca87366c03e2aed20468ca7e5.tar.bz2 |
[25842c161f] Ensure that finalization of a zlib stream works.
-rw-r--r-- | generic/tclZlib.c | 4 | ||||
-rw-r--r-- | tests/zlib.test | 42 |
2 files changed, 44 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..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] |