summaryrefslogtreecommitdiff
path: root/ext/zlib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/zlib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index db153e3694..918bad6b7d 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2709,7 +2709,7 @@ gzfile_read(struct gzfile *gz, long len)
if (len == 0) return rb_str_new(0, 0);
if (len < 0) return Qnil;
dst = zstream_shift_buffer(&gz->z, len);
- gzfile_calc_crc(gz, dst);
+ if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
return dst;
}
@@ -2772,6 +2772,7 @@ gzfile_read_all(struct gzfile *gz)
}
dst = zstream_detach_buffer(&gz->z);
+ if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
OBJ_TAINT(dst);
return gzfile_newstr(gz, dst);
@@ -2818,6 +2819,7 @@ gzfile_getc(struct gzfile *gz)
buf = gz->z.buf;
len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
dst = gzfile_read(gz, len);
+ if (NIL_P(dst)) return dst;
return gzfile_newstr(gz, dst);
}
}
@@ -4039,6 +4041,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
n = limit;
}
dst = zstream_shift_buffer(&gz->z, n);
+ if (NIL_P(dst)) return dst;
gzfile_calc_crc(gz, dst);
dst = gzfile_newstr(gz, dst);
}
@@ -4100,6 +4103,7 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
gz->lineno++;
dst = gzfile_read(gz, n);
+ if (NIL_P(dst)) return dst;
if (rspara) {
gzreader_skip_linebreaks(gz);
}