diff options
author | Joao Matos <joao@tritao.eu> | 2016-10-27 22:35:20 +0300 |
---|---|---|
committer | Joao Matos <joao@tritao.eu> | 2016-10-28 00:01:21 +0300 |
commit | dd0745f42631963648f7372689cbe4805400285f (patch) | |
tree | d801f882ac4cb29e0e338ec69f0423fe8ba578ff /support | |
parent | 0b94fdf1d36d923a1f1f5c16f3500a1769228f6e (diff) |
[System.IO.Compression] Fixed potential bug when keeping track of total read bytes of input stream.
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.
Diffstat (limited to 'support')
-rw-r--r-- | support/zlib-helper.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/support/zlib-helper.c b/support/zlib-helper.c index 5a33d0f2b8e..9dcebc7e967 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -194,9 +194,10 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length) 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) |