diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gunzip.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gunzip.c b/src/gunzip.c index fb0da05..2b30d46 100644 --- a/src/gunzip.c +++ b/src/gunzip.c @@ -177,12 +177,15 @@ static void gzo_close(void *stream) struct apk_gzip_ostream *gos = (struct apk_gzip_ostream *) stream; unsigned char buffer[1024]; size_t have; + int r; - gos->zs.avail_out = sizeof(buffer); - gos->zs.next_out = buffer; - deflate(&gos->zs, Z_FINISH); - have = sizeof(buffer) - gos->zs.avail_out; - gos->output->write(gos->output, buffer, have); + do { + gos->zs.avail_out = sizeof(buffer); + gos->zs.next_out = buffer; + r = deflate(&gos->zs, Z_FINISH); + have = sizeof(buffer) - gos->zs.avail_out; + gos->output->write(gos->output, buffer, have); + } while (r == Z_OK); gos->output->close(gos->output); deflateEnd(&gos->zs); |