summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-26 02:39:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-26 02:39:00 +0000
commit34d4105556511e811fd632af7a7cebe970c08854 (patch)
treeb6e03e3b5ccbf92b0b8f5bd2f88e6bac4b02f107 /string.c
parent622f3f14b6928ee4fe3afa96db0250eb9da32e7a (diff)
downloadruby-34d4105556511e811fd632af7a7cebe970c08854.tar.gz
string.c: consider widechar
* string.c (str_make_independent_expand): consider wide char encoding. [Fix GH-821] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/string.c b/string.c
index ffe2e6233a..f29158acf9 100644
--- a/string.c
+++ b/string.c
@@ -1589,11 +1589,11 @@ str_make_independent_expand(VALUE str, long expand)
if (len > capa) len = capa;
- if (capa <= RSTRING_EMBED_LEN_MAX && !STR_EMBED_P(str)) {
+ if (capa + termlen - 1 <= RSTRING_EMBED_LEN_MAX && !STR_EMBED_P(str)) {
ptr = RSTRING(str)->as.heap.ptr;
STR_SET_EMBED(str);
memcpy(RSTRING(str)->as.ary, ptr, len);
- RSTRING(str)->as.ary[len] = '\0'; /* Ensure string is terminated */
+ TERM_FILL(RSTRING(str)->as.ary + len, termlen);
STR_SET_EMBED_LEN(str, len);
return;
}