]> git.lizzy.rs Git - zlib.git/blobdiff - deflate.c
Permit a deflateParams() parameter change as soon as possible.
[zlib.git] / deflate.c
index b63311a59d0d6f460da3e737cd2fc4efb1a598c1..20bda4f6a66db9e8e3a24cd32e2b3547b508cd4a 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm)
         s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
 #endif
         adler32(0L, Z_NULL, 0);
-    s->last_flush = Z_NO_FLUSH;
+    s->last_flush = -2;
 
     _tr_init(s);
 
@@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy)
     func = configuration_table[s->level].func;
 
     if ((strategy != s->strategy || func != configuration_table[level].func) &&
-        s->high_water) {
+        s->last_flush != -2) {
         /* Flush the last buffer: */
         int err = deflate(strm, Z_BLOCK);
         if (err == Z_STREAM_ERROR)
             return err;
-        if (strm->avail_out == 0)
+        if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
             return Z_BUF_ERROR;
     }
     if (s->level != level) {