diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-24 22:00:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-24 22:00:55 +0000 |
commit | 7a6113d6b683ab671e2476910962fbfd5e689617 (patch) | |
tree | 8c984feab222fa6fd2e75751c577a206c544520c /string.c | |
parent | 68823fdea5ea47cf056c95b4e45c48c66f55c157 (diff) | |
download | ruby-7a6113d6b683ab671e2476910962fbfd5e689617.tar.gz |
* string.c (rb_string_value_cstr): rb_str_modify can change
RSTRING_PTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1392,7 +1392,11 @@ rb_string_value_cstr(volatile VALUE *ptr) if (!s || memchr(s, 0, len)) { rb_raise(rb_eArgError, "string contains null byte"); } - if (s[len]) rb_str_modify(str); + if (s[len]) { + rb_str_modify(str); + s = RSTRING_PTR(str); + s[RSTRING_LEN(str)] = 0; + } return s; } |