[support] Limit possible values
authorMarek Habersack <grendel@twistedcode.net>
Fri, 25 Sep 2015 19:18:22 +0000 (21:18 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Fri, 25 Sep 2015 19:18:22 +0000 (21:18 +0200)
Value returned from the reader function can be negative and ZStream's
avail_in should not be less than 0 as that value makes no sense and
other parts of code assume it to be equal or higher than 0.

support/zlib-helper.c

index 38696260a092fb4b509f7eabc7f9fef96032b2b8..dbfd1c7e24a27e7dd67283e6c1df7401b17d6100 100644 (file)
@@ -187,7 +187,7 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length)
                                stream->eof = TRUE;
                        }
                        zs->next_in = stream->buffer;
-                       zs->avail_in = n;
+                       zs->avail_in = n < 0 ? 0 : n;
                }
 
                if (zs->avail_in == 0 && zs->total_in == 0)