summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrzemyslaw Szczepaniak <pszczepaniak@google.com>2018-01-22 15:40:56 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-01-22 15:40:56 +0000
commitfa5467efd7b02185711255ea83bbdc78dbdb91d0 (patch)
treeea70b7e5eb48dd55db7ea6f6aa4c3ef4b3d2e1e9
parent2c9c51f114436bc69fa15376a3e06c777dc4e6ff (diff)
parent32de7d459a10715b8e5f166d7af0e6935585baab (diff)
downloadzlib-fa5467efd7b02185711255ea83bbdc78dbdb91d0.tar.gz
Merge "Cherry-pick fix for 1.2.11 deterministic output regression" am: 1be35eaf4d am: 5613fd2c5f
am: 32de7d459a Change-Id: Ia60ebd57eeaf79601f4e876d6d03a503a2bbf1b9
-rw-r--r--src/deflate.c6
-rw-r--r--src/zlib.h11
2 files changed, 9 insertions, 8 deletions
diff --git a/src/deflate.c b/src/deflate.c
index 1ec7614..7f2c8a2 100644
--- a/src/deflate.c
+++ b/src/deflate.c
@@ -494,7 +494,7 @@ int ZEXPORT deflateResetKeep (strm)
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
#endif
adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
+ s->last_flush = -2;
_tr_init(s);
@@ -587,12 +587,12 @@ int ZEXPORT deflateParams(strm, level, strategy)
func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func) &&
- s->high_water) {
+ s->last_flush != -2) {
/* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR)
return err;
- if (strm->avail_out == 0)
+ if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
return Z_BUF_ERROR;
}
if (s->level != level) {
diff --git a/src/zlib.h b/src/zlib.h
index f09cdaf..001624e 100644
--- a/src/zlib.h
+++ b/src/zlib.h
@@ -712,11 +712,12 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the
- strategy is changed, and if any input has been consumed in a previous
- deflate() call, then the input available so far is compressed with the old
- level and strategy using deflate(strm, Z_BLOCK). There are three approaches
- for the compression levels 0, 1..3, and 4..9 respectively. The new level
- and strategy will take effect at the next call of deflate().
+ strategy is changed, and if there have been any deflate() calls since the
+ state was initialized or reset, then the input available so far is
+ compressed with the old level and strategy using deflate(strm, Z_BLOCK).
+ There are three approaches for the compression levels 0, 1..3, and 4..9
+ respectively. The new level and strategy will take effect at the next call
+ of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not