From be8b59dbe1525a5885bbe3737aa696a01004d633 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Mon, 20 Jul 2009 15:20:37 +0300 Subject: gzip: fix finalization of compressed output the unflushed data when closing file can be several thousand kiloes, loop until all is written out. --- src/gunzip.c | 13 ++++++++----- 1 file 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); -- cgit v1.2.3