summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2016-11-22 23:29:19 -0800
committerMark Adler <madler@alumni.caltech.edu>2016-12-04 07:48:47 -0800
commit7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140 (patch)
treec549e902ffc2e63b4ad12e2e60a8868c0e0573aa /deflate.c
parent1101ea79c65c6f42c33a1e3a5d5eef38c00a30a2 (diff)
downloadzlib-7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140.tar.gz
Assure that deflateParams() will not switch functions mid-block.
This alters the specification in zlib.h, so that deflateParams() will not change any parameters if there is not enough output space in the event that a block is emitted in order to allow switching the compression function.
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/deflate.c b/deflate.c
index 3d24cbc..0a78b5a 100644
--- a/deflate.c
+++ b/deflate.c
@@ -517,7 +517,6 @@ int ZEXPORT deflateParams(strm, level, strategy)
{
deflate_state *s;
compress_func func;
- int err = Z_OK;
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
@@ -534,9 +533,11 @@ int ZEXPORT deflateParams(strm, level, strategy)
if ((strategy != s->strategy || func != configuration_table[level].func)) {
/* Flush the last buffer: */
- err = deflate(strm, Z_BLOCK);
- if (err == Z_BUF_ERROR && s->pending == 0)
- err = Z_OK;
+ int err = deflate(strm, Z_BLOCK);
+ if (err == Z_STREAM_ERROR)
+ return err;
+ if (strm->avail_out == 0)
+ return Z_BUF_ERROR;
}
if (s->level != level) {
s->level = level;
@@ -546,7 +547,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
s->max_chain_length = configuration_table[level].max_chain;
}
s->strategy = strategy;
- return err;
+ return Z_OK;
}
/* ========================================================================= */