summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 23:00:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-31 23:00:48 +0000
commitaa8cc01aa398d231c9839bc24b7b138f2c75952f (patch)
tree729f50a906bf36c3a714689104376b35e535451d /ext
parent488f478d24019de88aa96944a0b91987ced37e12 (diff)
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
Diffstat (limited to 'ext')
-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 db153e36946..918bad6b7dd 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);
}