diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-03 04:52:13 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-03 04:52:13 +0000 |
commit | 90d0196dc33d18e281d9bbf8cc96bbeda4383179 (patch) | |
tree | 82fd70a465e7b4ff794d2bfd9806fb6ed29ebbeb /string.c | |
parent | 15f593de89a3b0b526261e9410cb32a3a95fda71 (diff) | |
download | ruby-90d0196dc33d18e281d9bbf8cc96bbeda4383179.tar.gz |
* string.c (str_new_frozen): if the given string is embeddedable
but not embedded, embed a new copied string. [Bug #11946]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1090,6 +1090,13 @@ str_new_frozen(VALUE klass, VALUE orig) return shared; } } + else if (RSTRING_LEN(orig)+TERM_LEN(orig) <= RSTRING_EMBED_LEN_MAX+1) { + str = str_alloc(klass); + STR_SET_EMBED(str); + memcpy(RSTRING_PTR(str), RSTRING_PTR(orig), RSTRING_LEN(orig)); + STR_SET_EMBED_LEN(str, RSTRING_LEN(orig)); + TERM_FILL(RSTRING_END(str), TERM_LEN(orig)); + } else { str = str_alloc(klass); STR_SET_NOEMBED(str); |