summaryrefslogtreecommitdiff
path: root/ext/stringio
diff options
context:
space:
mode:
authorheadius <headius@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-03 21:53:54 +0000
committerheadius <headius@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-03 21:53:54 +0000
commit7974fe6a78a3551ab682ced6cfabba27843a5cde (patch)
tree028e2d47a95bfd185e01920d921d7d01da160307 /ext/stringio
parent5a13ad0386552a8d7ad4a94fbd99a0a36b045a25 (diff)
* 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
Diffstat (limited to 'ext/stringio')
-rw-r--r--ext/stringio/stringio.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 5785491..ef3df83 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -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);
}