aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-27 21:54:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-07-27 21:54:34 +0900
commitf1b76ea63ce40670071a857f408a4747c571f1e9 (patch)
tree941d10f573698fca4cefb737bdd09b12e6081128 /string.c
parente3b613a66986306950fc69d426d947a349b9fc8b (diff)
downloadruby-f1b76ea63ce40670071a857f408a4747c571f1e9.tar.gz
Occupy match data
* string.c (rb_str_split_m): occupy match data not to be modified during yielding the block. [Bug #16024]
Diffstat (limited to 'string.c')
-rw-r--r--string.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/string.c b/string.c
index fcaf280baa..2805b4d2aa 100644
--- a/string.c
+++ b/string.c
@@ -8087,7 +8087,9 @@ rb_str_split_m(int argc, VALUE *argv, VALUE str)
struct re_registers *regs;
while ((end = rb_reg_search(spat, str, start, 0)) >= 0) {
- regs = RMATCH_REGS(rb_backref_get());
+ VALUE match = rb_backref_get();
+ if (!result) rb_match_busy(match);
+ regs = RMATCH_REGS(match);
if (start == end && BEG(0) == END(0)) {
if (!ptr) {
SPLIT_STR(0, 0);