From 2dcdfe76d02fed91b71e5b49b6028c6c82e10d4c Mon Sep 17 00:00:00 2001 From: Gabriel Garcia Date: Mon, 6 Apr 2015 13:59:43 -0400 Subject: [PATCH] [System] Fix DeflateStream throw on empty flush, double flush. Fixes #28777 diff --git a/support/zlib-helper.c b/support/zlib-helper.c index 8345541..3869626 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -90,6 +90,8 @@ CreateZStream (gint compress, guchar gzip, read_write_func func, void *gchandle) result->gchandle = gchandle; result->compress = compress; result->buffer = g_new (guchar, BUFFER_SIZE); + result->stream->next_out = result->buffer; + result->stream->avail_out = BUFFER_SIZE; return result; } @@ -148,7 +150,7 @@ flush_internal (ZStream *stream, gboolean is_final) if (!stream->compress) return 0; - if (!is_final) { + if (!is_final && stream->stream->avail_in != 0) { status = deflate (stream->stream, Z_PARTIAL_FLUSH); if (status != Z_OK && status != Z_STREAM_END) return status;