diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-04 06:54:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-04 06:54:11 +0000 |
commit | f61e53991e1dc3dd2a217aedb58a6cfe313f4e66 (patch) | |
tree | 6fa7140941e608b5c0fdca64de2682129743ba4c /parse.y | |
parent | 5ddf1965c560626b50307da33343468e6680b93f (diff) | |
download | ruby-f61e53991e1dc3dd2a217aedb58a6cfe313f4e66.tar.gz |
parse.y: make shared string modifiable
* parse.y (dedent_string): ensure that the string is modifiable,
not to set the length of shared string.
[ruby-core:80987] [Bug #13540]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -6392,6 +6392,11 @@ dedent_string(VALUE string, int width) break; } } + if (!i) return 0; + rb_str_modify(string); + str = RSTRING_PTR(string); + if (RSTRING_LEN(string) != len) + rb_fatal("literal string changed: %+"PRIsVALUE, string); MEMMOVE(str, str + i, char, len - i); rb_str_set_len(string, len - i); return i; @@ -6448,7 +6453,6 @@ parser_dedent_string(VALUE self, VALUE input, VALUE width) StringValue(input); wid = NUM2UINT(width); - rb_str_modify(input); col = dedent_string(input, wid); return INT2NUM(col); } |