From b8bd09801f4a2c224655e14edffc5793943a33d2 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Sun, 24 Jul 2022 11:41:07 -0700 Subject: [PATCH] Have infback() deliver all of the available output up to any error. --- infback.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/infback.c b/infback.c index 4c712a13..babeaf18 100644 --- a/infback.c +++ b/infback.c @@ -606,25 +606,27 @@ void FAR *out_desc; break; case DONE: - /* inflate stream terminated properly -- write leftover output */ + /* inflate stream terminated properly */ ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; - default: /* can't happen, but makes compilers happy */ + default: + /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } - /* Return unused input */ + /* Write leftover output and return unused input */ inf_leave: + if (left < state->wsize) { + if (out(out_desc, state->window, state->wsize - left) && + ret == Z_STREAM_END) + ret = Z_BUF_ERROR; + } strm->next_in = next; strm->avail_in = have; return ret;