diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2016-11-22 23:29:19 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2016-12-04 07:48:47 -0800 |
commit | 7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140 (patch) | |
tree | c549e902ffc2e63b4ad12e2e60a8868c0e0573aa /deflate.c | |
parent | 1101ea79c65c6f42c33a1e3a5d5eef38c00a30a2 (diff) | |
download | zlib-7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140.tar.gz zlib-7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140.tar.bz2 zlib-7161ad76e2d0ac7de2a6235fcad3b9dfc99e9140.zip |
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.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -517,7 +517,6 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
517 | { | 517 | { |
518 | deflate_state *s; | 518 | deflate_state *s; |
519 | compress_func func; | 519 | compress_func func; |
520 | int err = Z_OK; | ||
521 | 520 | ||
522 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; | 521 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
523 | s = strm->state; | 522 | s = strm->state; |
@@ -534,9 +533,11 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
534 | 533 | ||
535 | if ((strategy != s->strategy || func != configuration_table[level].func)) { | 534 | if ((strategy != s->strategy || func != configuration_table[level].func)) { |
536 | /* Flush the last buffer: */ | 535 | /* Flush the last buffer: */ |
537 | err = deflate(strm, Z_BLOCK); | 536 | int err = deflate(strm, Z_BLOCK); |
538 | if (err == Z_BUF_ERROR && s->pending == 0) | 537 | if (err == Z_STREAM_ERROR) |
539 | err = Z_OK; | 538 | return err; |
539 | if (strm->avail_out == 0) | ||
540 | return Z_BUF_ERROR; | ||
540 | } | 541 | } |
541 | if (s->level != level) { | 542 | if (s->level != level) { |
542 | s->level = level; | 543 | s->level = level; |
@@ -546,7 +547,7 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
546 | s->max_chain_length = configuration_table[level].max_chain; | 547 | s->max_chain_length = configuration_table[level].max_chain; |
547 | } | 548 | } |
548 | s->strategy = strategy; | 549 | s->strategy = strategy; |
549 | return err; | 550 | return Z_OK; |
550 | } | 551 | } |
551 | 552 | ||
552 | /* ========================================================================= */ | 553 | /* ========================================================================= */ |