the chunkset code to spill garbage data into the padding area if available.
strm->state = (struct internal_state *)state;
state->wbits = (unsigned int)windowBits;
state->wsize = 1U << windowBits;
+ state->wbufsize = 1U << windowBits;
state->window = window;
state->wnext = 0;
state->whave = 0;
/* Detect if out and window point to the same memory allocation. In this instance it is
necessary to use safe chunk copy functions to prevent overwriting the window. If the
window is overwritten then future matches with far distances will fail to copy correctly. */
- extra_safe = (wsize != 0 && out >= window && out + INFLATE_FAST_MIN_LEFT <= window + wsize);
+ extra_safe = (wsize != 0 && out >= window && out + INFLATE_FAST_MIN_LEFT <= window + state->wbufsize);
#define REFILL() do { \
hold |= load_64_bits(in, bits); \
state = alloc_bufs->state;
state->window = alloc_bufs->window;
state->alloc_bufs = alloc_bufs;
+ state->wbufsize = INFLATE_ADJUST_WINDOW_SIZE((1 << MAX_WBITS) + 64);
Tracev((stderr, "inflate: allocated\n"));
strm->state = (struct internal_state *)state;
/* sliding window */
unsigned wbits; /* log base 2 of requested window size */
uint32_t wsize; /* window size or zero if not using window */
+ uint32_t wbufsize; /* real size of the allocated window buffer, including padding */
uint32_t whave; /* valid bytes in the window */
uint32_t wnext; /* window write index */
unsigned char *window; /* allocated sliding window, if needed */