summaryrefslogtreecommitdiff
path: root/gzwrite.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2019-04-13 17:05:16 -0700
committerHans Kristian Rosbach <hk-github@circlestorm.org>2019-10-22 09:55:41 +0200
commit72c9ed141529150513f30ce3a15db03f2fd066d4 (patch)
tree0bc75d3b45ec3eca57fbc772996c3d9d55d9e385 /gzwrite.c
parentfee07f25eeb0aa33abbd1c4d8b01a9e22e02c822 (diff)
Avoid adding empty gzip member after gzflush with Z_FINISH.
Diffstat (limited to 'gzwrite.c')
-rw-r--r--gzwrite.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gzwrite.c b/gzwrite.c
index 5b12805..b98022e 100644
--- a/gzwrite.c
+++ b/gzwrite.c
@@ -91,6 +91,15 @@ static int gz_comp(gz_state *state, int flush) {
return 0;
}
+ /* check for a pending reset */
+ if (state->reset) {
+ /* don't start a new gzip member unless there is data to write */
+ if (strm->avail_in == 0)
+ return 0;
+ PREFIX(deflateReset)(strm);
+ state->reset = 0;
+ }
+
/* run deflate() on provided input until it produces no more output */
ret = Z_OK;
do {
@@ -122,8 +131,7 @@ static int gz_comp(gz_state *state, int flush) {
/* if that completed a deflate stream, allow another to start */
if (flush == Z_FINISH)
- PREFIX(deflateReset)(strm);
-
+ state->reset = 1;
/* all done, no errors */
return 0;
}