arrfab / rpms / zlib

Forked from rpms/zlib 5 years ago
Clone

Blame SOURCES/zlib-1.2.7-z-block-flush.patch

bbbb7a
From f1b8edadc3c733990f8a8de4d643f968e571ae85 Mon Sep 17 00:00:00 2001
bbbb7a
From: Adam Tkac <atkac@redhat.com>
bbbb7a
Date: Fri, 17 Aug 2012 15:13:48 +0200
bbbb7a
Subject: [PATCH] Rank Z_BLOCK flush below Z_PARTIAL_FLUSH only when last
bbbb7a
 flush was Z_BLOCK.
bbbb7a
bbbb7a
This fixes regression introduced by f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9
bbbb7a
(Permit stronger flushes after Z_BLOCK flushes.). Now this code is valid
bbbb7a
again:
bbbb7a
bbbb7a
deflate(stream, Z_SYNC_FLUSH);
bbbb7a
deflateParams(stream, newLevel, Z_DEFAULT_STRATEGY);
bbbb7a
bbbb7a
Signed-off-by: Adam Tkac <atkac@redhat.com>
bbbb7a
---
bbbb7a
 deflate.c | 13 ++++++++++---
bbbb7a
 1 file changed, 10 insertions(+), 3 deletions(-)
bbbb7a
bbbb7a
diff --git a/deflate.c b/deflate.c
bbbb7a
index 9e4c2cb..3422f72 100644
bbbb7a
--- a/deflate.c
bbbb7a
+++ b/deflate.c
bbbb7a
@@ -882,9 +882,16 @@ int ZEXPORT deflate (strm, flush)
bbbb7a
      * flushes. For repeated and useless calls with Z_FINISH, we keep
bbbb7a
      * returning Z_STREAM_END instead of Z_BUF_ERROR.
bbbb7a
      */
bbbb7a
-    } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
bbbb7a
-               flush != Z_FINISH) {
bbbb7a
-        ERR_RETURN(strm, Z_BUF_ERROR);
bbbb7a
+    } else if (strm->avail_in == 0 && flush != Z_FINISH) {
bbbb7a
+        char err;
bbbb7a
+
bbbb7a
+        /* Degrade Z_BLOCK only when last flush was Z_BLOCK */
bbbb7a
+        err = (old_flush == Z_BLOCK) ?
bbbb7a
+              RANK(flush) <= RANK(old_flush) : flush <= old_flush;
bbbb7a
+
bbbb7a
+        if (err) {
bbbb7a
+            ERR_RETURN(strm, Z_BUF_ERROR);
bbbb7a
+        }
bbbb7a
     }
bbbb7a
 
bbbb7a
     /* User must not provide more input after the first FINISH: */
bbbb7a
-- 
bbbb7a
1.7.11.4
bbbb7a