1 --- misc/zlib-1.2.3/deflate.c
2 +++ misc/build/zlib-1.2.3/deflate.c
4 s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
5 s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
7 + s->high_water = 0; /* nothing written to s->window yet */
9 s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
11 overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
12 @@ -1355,6 +1355,40 @@
15 } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
17 + /* If the WIN_INIT bytes after the end of the current data have never been
18 + * written, then zero those bytes in order to avoid memory check reports of
19 + * the use of uninitialized (or uninitialised as Julian writes) bytes by
20 + * the longest match routines. Update the high water mark for the next
21 + * time through here. WIN_INIT is set to MAX_MATCH since the longest match
22 + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
24 + if (s->high_water < s->window_size) {
25 + ulg curr = s->strstart + (ulg)(s->lookahead);
28 + if (s->high_water < curr) {
29 + /* Previous high water mark below current data -- zero WIN_INIT
30 + * bytes or up to end of window, whichever is less.
32 + init = s->window_size - curr;
33 + if (init > WIN_INIT)
35 + zmemzero(s->window + curr, (unsigned)init);
36 + s->high_water = curr + init;
38 + else if (s->high_water < (ulg)curr + WIN_INIT) {
39 + /* High water mark at or above current data, but below current data
40 + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
41 + * to end of window, whichever is less.
43 + init = (ulg)curr + WIN_INIT - s->high_water;
44 + if (init > s->window_size - s->high_water)
45 + init = s->window_size - s->high_water;
46 + zmemzero(s->window + s->high_water, (unsigned)init);
47 + s->high_water += init;
52 /* ===========================================================================
53 --- misc/zlib-1.2.3/deflate.h
54 +++ misc/build/zlib-1.2.3/deflate.h
60 + /* High water mark offset in window for initialized bytes -- bytes above
61 + * this are set to zero in order to avoid memory check warnings when
62 + * longest match routines access bytes past the input. This is then
63 + * updated to the new high water mark.
67 /* Output a byte on the stream.
69 * distances are limited to MAX_DIST instead of WSIZE.
72 +#define WIN_INIT MAX_MATCH
73 +/* Number of bytes after end of data in window to initialize in order to avoid
74 + memory checker errors from longest match routines */
77 void _tr_init OF((deflate_state *s));
78 int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));