Have inflate() with Z_FINISH avoid the allocation of a window.

inflate() avoided that allocation normally, until it was modified to
update the window on a normal completion so that inflateResetKeep()
could work.  This patch restores that behavior, but only when
Z_FINISH is used successfully to complete an inflation of a stream in
a single call of inflate().  The comments in zlib.h have been updated
accordingly.
This commit is contained in:
Mark Adler
2011-12-08 19:03:56 -08:00
parent fb00fda903
commit 421c7a61f0
2 changed files with 16 additions and 10 deletions

View File

@@ -1232,7 +1232,8 @@ int flush;
*/
inf_leave:
RESTORE();
if (state->wsize || (state->mode < BAD && out != strm->avail_out))
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
(state->mode < CHECK || flush != Z_FINISH)))
if (updatewindow(strm, out)) {
state->mode = MEM;
return Z_MEM_ERROR;