summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-24 17:54:53 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-10-24 17:54:53 +0000
commit23219d9c798f84ce7bef9d908f0e4e17056892fd (patch)
tree9cbcf428287ee4de31b1c55f110f19303cd8b746 /string.c
parentfff4b0e674521d8e399562285b63d28ff708d85c (diff)
downloadruby-23219d9c798f84ce7bef9d908f0e4e17056892fd.tar.gz
ruby-23219d9c798f84ce7bef9d908f0e4e17056892fd.tar.xz
ruby-23219d9c798f84ce7bef9d908f0e4e17056892fd.zip
* string.c (rb_str_split_m): RSTRING(str)->ptr might become NULL.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/string.c b/string.c
index 57e0cad81..3f1445fb5 100644
--- a/string.c
+++ b/string.c
@@ -2533,7 +2533,11 @@ rb_str_split_m(argc, argv, str)
while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
regs = RMATCH(rb_backref_get())->regs;
if (start == end && BEG(0) == END(0)) {
- if (last_null == 1) {
+ if (!RSTRING(str)->ptr) {
+ rb_ary_push(result, rb_str_new("", 0));
+ break;
+ }
+ else if (last_null == 1) {
rb_ary_push(result, rb_str_substr(str, beg, mbclen2(RSTRING(str)->ptr[beg],spat)));
beg = start;
}