summaryrefslogtreecommitdiff
path: root/ext/zlib/zlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zlib/zlib.c')
-rw-r--r--ext/zlib/zlib.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 38ab667cd4..0e9d9a679a 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2072,7 +2072,10 @@ gzfile_read(gz, len)
{
VALUE dst;
- if (len <= 0) return Qnil;
+ if (len < 0)
+ rb_raise(rb_eArgError, "negative length %d given", len);
+ if (len == 0)
+ return rb_str_new(0, 0);
while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
gzfile_read_more(gz);
}