gzip: fix finalization of compressed output
the unflushed data when closing file can be several thousand kiloes, loop until all is written out.cute-signatures
parent
89d1abe4e6
commit
be8b59dbe1
13
src/gunzip.c
13
src/gunzip.c
|
@ -177,12 +177,15 @@ static void gzo_close(void *stream)
|
||||||
struct apk_gzip_ostream *gos = (struct apk_gzip_ostream *) stream;
|
struct apk_gzip_ostream *gos = (struct apk_gzip_ostream *) stream;
|
||||||
unsigned char buffer[1024];
|
unsigned char buffer[1024];
|
||||||
size_t have;
|
size_t have;
|
||||||
|
int r;
|
||||||
|
|
||||||
gos->zs.avail_out = sizeof(buffer);
|
do {
|
||||||
gos->zs.next_out = buffer;
|
gos->zs.avail_out = sizeof(buffer);
|
||||||
deflate(&gos->zs, Z_FINISH);
|
gos->zs.next_out = buffer;
|
||||||
have = sizeof(buffer) - gos->zs.avail_out;
|
r = deflate(&gos->zs, Z_FINISH);
|
||||||
gos->output->write(gos->output, buffer, have);
|
have = sizeof(buffer) - gos->zs.avail_out;
|
||||||
|
gos->output->write(gos->output, buffer, have);
|
||||||
|
} while (r == Z_OK);
|
||||||
gos->output->close(gos->output);
|
gos->output->close(gos->output);
|
||||||
|
|
||||||
deflateEnd(&gos->zs);
|
deflateEnd(&gos->zs);
|
||||||
|
|
Loading…
Reference in New Issue