Blob Blame History Raw
From 27a4fb5e54884c06fc0face8b4b432fa06dce773 Mon Sep 17 00:00:00 2001
From: Adam Tkac <atkac@redhat.com>
Date: Fri, 17 Aug 2012 15:13:48 +0200
Subject: [PATCH] Rank Z_BLOCK flush below Z_PARTIAL_FLUSH only when last
 flush was Z_BLOCK.

This fixes regression introduced by f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9
(Permit stronger flushes after Z_BLOCK flushes.). Now this code is valid
again:

deflate(stream, Z_SYNC_FLUSH);
deflateParams(stream, newLevel, Z_DEFAULT_STRATEGY);

Signed-off-by: Adam Tkac <atkac@redhat.com>
---
 deflate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/deflate.c b/deflate.c
index 9e4c2cb..d1d0c68 100644
--- a/deflate.c
+++ b/deflate.c
@@ -882,8 +882,8 @@ int ZEXPORT deflate (strm, flush)
      * flushes. For repeated and useless calls with Z_FINISH, we keep
      * returning Z_STREAM_END instead of Z_BUF_ERROR.
      */
-    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
-               flush != Z_FINISH) {
+    } else if (strm->avail_in == 0 && old_flush == Z_BLOCK &&
+               RANK(flush) <= RANK(old_flush) && flush != Z_FINISH) {
         ERR_RETURN(strm, Z_BUF_ERROR);
     }
 
-- 
1.7.11.4