From aa8cc01aa398d231c9839bc24b7b138f2c75952f Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 31 May 2013 23:00:48 +0000 Subject: zlib.c: check EOF * ext/zlib/zlib.c (gzfile_read, gzfile_read_all, gzfile_getc), (gzreader_gets): check EOF. [ruby-core:55220] [Bug #8467] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/zlib/zlib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ext/zlib') 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); } -- cgit v1.2.3