summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-23 07:09:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-23 07:09:07 +0000
commit8c59fdb8d8f3144570019ee501e508a6ebd9575b (patch)
tree4423bd9c236083a4a020a444b9b1f4dd860b0349 /string.c
parente1be1d0c3815be2819f525e3c1d1ec34ccdc398b (diff)
dup String#split return value
* string.c (rb_str_split): return duplicated receiver, when no splits. patched by tompng (tomoya ishida) in [ruby-core:82911], and the test case by Seiei Miyagi <hanachin@gmail.com>. [Bug#13925] [Fix GH-1705] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60002 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 ad19595f67..7e7ae7f0a8 100644
--- a/string.c
+++ b/string.c
@@ -7371,7 +7371,7 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
else if (lim == 1) {
if (RSTRING_LEN(str) == 0)
return rb_ary_new2(0);
- return rb_ary_new3(1, str);
+ return rb_ary_new3(1, rb_str_dup(str));
}
i = 1;
}