This didn't manifest as a bug, to to be on the safe side, replicate the behavior
introduced in https://github.com/mono/mono/commit/
b4d5016b5e42fec226d93fd13260b6cac80eb384
and use the same approach when calculating the total of the read bytes of the input stream.
while (zs->avail_out > 0) {
if (zs->avail_in == 0) {
n = stream->func (stream->buffer, BUFFER_SIZE, stream->gchandle);
+ n = n < 0 ? 0 : n;
stream->total_in += n;
zs->next_in = stream->buffer;
- zs->avail_in = n < 0 ? 0 : n;
+ zs->avail_in = n;
}
if (zs->avail_in == 0 && zs->total_in == 0)