summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-23 07:09:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-23 07:09:05 +0000
commitb0326bce01af3c6c29a29672875b6618964088bc (patch)
tree3e3472ad910774ff26413b732c7d526733ba6039 /string.c
parent80aa804a3372424e91bd4b01cffd4600b63bbd54 (diff)
dup String#partition return value
* string.c (rb_str_partition): return duplicated receiver, when no splits. [ruby-core:82911] [Bug#13925] Author: Seiei Miyagi <hanachin@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index bbd23669e6..6cf76e4fd4 100644
--- a/string.c
+++ b/string.c
@@ -9124,7 +9124,7 @@ rb_str_partition(VALUE str, VALUE sep)
pos = rb_reg_search(sep, str, 0, 0);
if (pos < 0) {
failed:
- return rb_ary_new3(3, str, str_new_empty(str), str_new_empty(str));
+ return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str));
}
sep = rb_str_subpat(str, sep, INT2FIX(0));
if (pos == 0 && RSTRING_LEN(sep) == 0) goto failed;