Do not return Z_BUF_ERROR if deflateParam() has nothing to write.
authorMark Adler <madler@alumni.caltech.edu>
Mon, 25 Mar 2013 05:12:31 +0000 (22:12 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Mon, 25 Mar 2013 05:15:04 +0000 (22:15 -0700)
If the compressed data was already at a block boundary, then
deflateParam() would report Z_BUF_ERROR, because there was nothing
to write.  With this patch, Z_OK is returned in that case.

deflate.c

index 4aa5afb9457d73ccf3eddb98a67ff7508237ab9e..a942e25286949323d0d9ce8254bd666a964ea52e 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -513,6 +513,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
         strm->total_in != 0) {
         /* Flush the last buffer: */
         err = deflate(strm, Z_BLOCK);
+        if (err == Z_BUF_ERROR && s->pending == 0)
+            err = Z_OK;
     }
     if (s->level != level) {
         s->level = level;