aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 08:26:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-10 08:26:40 +0000
commit71dc2cfe04b7b560b87d95f32d3bb06233c726e8 (patch)
tree46b9a19616bda92969b59bfbff83d35f83cbc1ca /ext
parent9b18f4d60aa162b536c2cb895383b69687e58ced (diff)
downloadruby-71dc2cfe04b7b560b87d95f32d3bb06233c726e8.tar.gz
zlib.c: replace with substring
* ext/zlib/zlib.c (zstream_discard_input): replace with unread portion substring, not modifying the input buffer directly. [ruby-core:78567] [Bug #13021] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/zlib/zlib.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 956ff08b53..232ad0b13b 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -879,9 +879,8 @@ zstream_discard_input(struct zstream *z, long len)
z->input = Qnil;
}
else {
- memmove(RSTRING_PTR(z->input), RSTRING_PTR(z->input) + len,
- RSTRING_LEN(z->input) - len);
- rb_str_resize(z->input, RSTRING_LEN(z->input) - len);
+ z->input = rb_str_substr(z->input, len,
+ RSTRING_LEN(z->input) - len);
}
}
@@ -2406,9 +2405,7 @@ gzfile_read_raw_ensure(struct gzfile *gz, long size)
VALUE str;
if (gz->io == Qundef) { /* Zlib.gunzip */
- if (NIL_P(gz->z.input))
- rb_bug("unexpected condition: both gz->io and gz->z.input are nil");
- if (RSTRING_LEN(gz->z.input) < size)
+ if (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size)
rb_raise(cGzError, "unexpected end of string");
}
while (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size) {