Skip to content
Snippets Groups Projects
Commit 79baebe5 authored by Mark Adler's avatar Mark Adler
Browse files

Avoid adding empty gzip member after gzflush with Z_FINISH.

parent 0e96d8e7
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -190,6 +190,7 @@ typedef struct {
/* just for writing */
int level; /* compression level */
int strategy; /* compression strategy */
int reset; /* true if a reset is pending after a Z_FINISH */
/* seek request */
z_off64_t skip; /* amount to skip (already rewound if backwards) */
int seek; /* true if seek request pending */
Loading
Loading
Loading
Loading
@@ -81,6 +81,8 @@ local void gz_reset(state)
state->past = 0; /* have not read past end yet */
state->how = LOOK; /* look for gzip header */
}
else /* for writing ... */
state->reset = 0; /* no deflateReset pending */
state->seek = 0; /* no seek request pending */
gz_error(state, Z_OK, NULL); /* clear error */
state->x.pos = 0; /* no uncompressed data yet */
Loading
Loading
Loading
Loading
@@ -97,6 +97,15 @@ local int gz_comp(state, 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;
deflateReset(strm);
state->reset = 0;
}
/* run deflate() on provided input until it produces no more output */
ret = Z_OK;
do {
Loading
Loading
@@ -134,7 +143,7 @@ local int gz_comp(state, flush)
 
/* if that completed a deflate stream, allow another to start */
if (flush == Z_FINISH)
deflateReset(strm);
state->reset = 1;
 
/* all done, no errors */
return 0;
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment