aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-17 10:15:28 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-17 10:15:28 +0000
commit648bf74fa2eea99496f000f5e3c00e3a9115ce54 (patch)
tree9cd8993f4d68151514f9f7dea5c23ec1947ed638 /string.c
parent8f44571b1a20eb4de52738ca1d4a17c3c3c74944 (diff)
downloadruby-648bf74fa2eea99496f000f5e3c00e3a9115ce54.tar.gz
Additional fix and tests for r53851
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/string.c b/string.c
index a72503e999..73e9492e7e 100644
--- a/string.c
+++ b/string.c
@@ -1383,6 +1383,7 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
vcapa = kwargs[1];
if (vcapa != Qundef && !NIL_P(vcapa)) {
long capa = NUM2LONG(vcapa);
+ str_discard(str);
if (capa < STR_BUF_MIN_SIZE) {
capa = STR_BUF_MIN_SIZE;
}
@@ -1405,6 +1406,7 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
}
else if (n == 1) {
StringValue(orig);
+ str_discard(str);
str_replace(str, orig);
}
if (enc != Qundef && !NIL_P(enc)) {
@@ -1414,9 +1416,7 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
}
else if (n == 1) {
StringValue(orig);
- if (OBJ_FROZEN(str)) {
- rb_error_frozen_object(str);
- }
+ str_discard(str);
str_replace(str, orig);
}
return str;