arrfab / rpms / zlib

Forked from rpms/zlib 5 years ago
Clone

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

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