5252#include "deflate.h"
5353
5454const char deflate_copyright [] =
55- " deflate 1.2.10 Copyright 1995-2017 Jean-loup Gailly and Mark Adler " ;
55+ " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler " ;
5656/*
5757 If you use the zlib library in a product, an acknowledgment is welcome
5858 in the documentation of your product. If for some reason you cannot
@@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
586586 }
587587 func = configuration_table [s -> level ].func ;
588588
589- if ((strategy != s -> strategy || func != configuration_table [level ].func )) {
589+ if ((strategy != s -> strategy || func != configuration_table [level ].func ) &&
590+ s -> high_water ) {
590591 /* Flush the last buffer: */
591592 int err = deflate (strm , Z_BLOCK );
592593 if (err == Z_STREAM_ERROR )
@@ -1671,8 +1672,6 @@ local block_state deflate_stored(s, flush)
16711672 len = left + s -> strm -> avail_in ; /* limit len to the input */
16721673 if (len > have )
16731674 len = have ; /* limit len to the output */
1674- if (left > len )
1675- left = len ; /* limit window pull to len */
16761675
16771676 /* If the stored block would be less than min_block in length, or if
16781677 * unable to copy all of the available input when flushing, then try
@@ -1681,13 +1680,13 @@ local block_state deflate_stored(s, flush)
16811680 */
16821681 if (len < min_block && ((len == 0 && flush != Z_FINISH ) ||
16831682 flush == Z_NO_FLUSH ||
1684- len - left != s -> strm -> avail_in ))
1683+ len != left + s -> strm -> avail_in ))
16851684 break ;
16861685
16871686 /* Make a dummy stored block in pending to get the header bytes,
16881687 * including any pending bits. This also updates the debugging counts.
16891688 */
1690- last = flush == Z_FINISH && len - left == s -> strm -> avail_in ? 1 : 0 ;
1689+ last = flush == Z_FINISH && len == left + s -> strm -> avail_in ? 1 : 0 ;
16911690 _tr_stored_block (s , (char * )0 , 0L , last );
16921691
16931692 /* Replace the lengths in the dummy stored block with len. */
@@ -1699,14 +1698,16 @@ local block_state deflate_stored(s, flush)
16991698 /* Write the stored block header bytes. */
17001699 flush_pending (s -> strm );
17011700
1702- /* Update debugging counts for the data about to be copied. */
17031701#ifdef ZLIB_DEBUG
1702+ /* Update debugging counts for the data about to be copied. */
17041703 s -> compressed_len += len << 3 ;
17051704 s -> bits_sent += len << 3 ;
17061705#endif
17071706
17081707 /* Copy uncompressed bytes from the window to next_out. */
17091708 if (left ) {
1709+ if (left > len )
1710+ left = len ;
17101711 zmemcpy (s -> strm -> next_out , s -> window + s -> block_start , left );
17111712 s -> strm -> next_out += left ;
17121713 s -> strm -> avail_out -= left ;
@@ -1756,6 +1757,8 @@ local block_state deflate_stored(s, flush)
17561757 s -> block_start = s -> strstart ;
17571758 s -> insert += MIN (used , s -> w_size - s -> insert );
17581759 }
1760+ if (s -> high_water < s -> strstart )
1761+ s -> high_water = s -> strstart ;
17591762
17601763 /* If the last block was written to next_out, then done. */
17611764 if (last )
@@ -1783,6 +1786,8 @@ local block_state deflate_stored(s, flush)
17831786 read_buf (s -> strm , s -> window + s -> strstart , have );
17841787 s -> strstart += have ;
17851788 }
1789+ if (s -> high_water < s -> strstart )
1790+ s -> high_water = s -> strstart ;
17861791
17871792 /* There was not enough avail_out to write a complete worthy or flushed
17881793 * stored block to next_out. Write a stored block to pending instead, if we
0 commit comments