diff options
-rw-r--r-- | support/ChangeLog | 4 | ||||
-rw-r--r-- | support/zlib-helper.c | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/support/ChangeLog b/support/ChangeLog index 73d71676a16..4465714868b 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,7 @@ +2010-04-19 Gonzalo Paniagua Javier <gonzalo@novell.com> + + * zlib-helper.c: don't call Z_FINISH if nothing has been written. + 2010-04-07 Gonzalo Paniagua Javier <gonzalo@novell.com> * zlib-helper.c: now that we don't use Z_SYNC_FLUSH, there might be diff --git a/support/zlib-helper.c b/support/zlib-helper.c index 23c662bf74d..66b58663a5e 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -103,12 +103,14 @@ CloseZStream (ZStream *zstream) status = 0; if (zstream->compress) { - do { - status = deflate (zstream->stream, Z_FINISH); - flush_status = Flush (zstream); - } while (status == Z_OK); /* We want Z_STREAM_END or error here here */ - if (status == Z_STREAM_END) - status = flush_status; + if (zstream->stream->total_in > 0) { + do { + status = deflate (zstream->stream, Z_FINISH); + flush_status = Flush (zstream); + } while (status == Z_OK); /* We want Z_STREAM_END or error here here */ + if (status == Z_STREAM_END) + status = flush_status; + } deflateEnd (zstream->stream); } else { inflateEnd (zstream->stream); |