1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/stringio/stringio.c (strio_substr): Trivial fix for invalid

pointer when len = 0 and pos outside of string. Bug #8728.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
headius 2013-08-03 21:53:54 +00:00
parent 5a13ad0386
commit 7974fe6a78

View file

@ -102,6 +102,7 @@ strio_substr(struct StringIO *ptr, long pos, long len)
if (len > rlen) len = rlen;
if (len < 0) len = 0;
if (len == 0) return rb_str_new(0,0);
return rb_enc_str_new(RSTRING_PTR(str)+pos, len, enc);
}