Adapt prev 4f78696117ebe4f729880b5d9bfc2f5817b73543 to 3.5 rtl::OUString
[LibreOffice.git] / zlib / zlib-valgrind.patch
blob3789ee4b13eca9d5d0ee095e8586e3d49e39732d
1 --- misc/zlib-1.2.3/deflate.c
2 +++ misc/build/zlib-1.2.3/deflate.c
3 @@ -288,6 +288,8 @@
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.
23 + */
24 + if (s->high_water < s->window_size) {
25 + ulg curr = s->strstart + (ulg)(s->lookahead);
26 + ulg init;
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.
31 + */
32 + init = s->window_size - curr;
33 + if (init > WIN_INIT)
34 + init = WIN_INIT;
35 + zmemzero(s->window + curr, (unsigned)init);
36 + s->high_water = curr + init;
37 + }
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.
42 + */
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;
48 + }
49 + }
52 /* ===========================================================================
53 --- misc/zlib-1.2.3/deflate.h
54 +++ misc/build/zlib-1.2.3/deflate.h
55 @@ -260,6 +260,12 @@
56 * are always zero.
59 + ulg high_water;
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.
64 + */
65 } FAR deflate_state;
67 /* Output a byte on the stream.
68 @@ -278,6 +284,10 @@
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 */
76 /* in trees.c */
77 void _tr_init OF((deflate_state *s));
78 int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));