arrfab / rpms / zlib

Forked from rpms/zlib 5 years ago
Clone

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

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