1 |
From f1b8edadc3c733990f8a8de4d643f968e571ae85 Mon Sep 17 00:00:00 2001 |
2 |
From: Adam Tkac <atkac@redhat.com> |
3 |
Date: Fri, 17 Aug 2012 15:13:48 +0200 |
4 |
Subject: [PATCH] Rank Z_BLOCK flush below Z_PARTIAL_FLUSH only when last |
5 |
flush was Z_BLOCK. |
6 |
|
7 |
This fixes regression introduced by f1ebdd6a9c495a5db9a22aa80dd7d54ae7db42e9 |
8 |
(Permit stronger flushes after Z_BLOCK flushes.). Now this code is valid |
9 |
again: |
10 |
|
11 |
deflate(stream, Z_SYNC_FLUSH); |
12 |
deflateParams(stream, newLevel, Z_DEFAULT_STRATEGY); |
13 |
|
14 |
Signed-off-by: Adam Tkac <atkac@redhat.com> |
15 |
--- |
16 |
deflate.c | 13 ++++++++++--- |
17 |
1 file changed, 10 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/deflate.c b/deflate.c |
20 |
index 9e4c2cb..3422f72 100644 |
21 |
--- a/deflate.c |
22 |
+++ b/deflate.c |
23 |
@@ -882,9 +882,16 @@ int ZEXPORT deflate (strm, flush) |
24 |
* flushes. For repeated and useless calls with Z_FINISH, we keep |
25 |
* returning Z_STREAM_END instead of Z_BUF_ERROR. |
26 |
*/ |
27 |
- } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && |
28 |
- flush != Z_FINISH) { |
29 |
- ERR_RETURN(strm, Z_BUF_ERROR); |
30 |
+ } else if (strm->avail_in == 0 && flush != Z_FINISH) { |
31 |
+ char err; |
32 |
+ |
33 |
+ /* Degrade Z_BLOCK only when last flush was Z_BLOCK */ |
34 |
+ err = (old_flush == Z_BLOCK) ? |
35 |
+ RANK(flush) <= RANK(old_flush) : flush <= old_flush; |
36 |
+ |
37 |
+ if (err) { |
38 |
+ ERR_RETURN(strm, Z_BUF_ERROR); |
39 |
+ } |
40 |
} |
41 |
|
42 |
/* User must not provide more input after the first FINISH: */ |
43 |
-- |
44 |
1.7.11.4 |
45 |
|