From f1b76ea63ce40670071a857f408a4747c571f1e9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 27 Jul 2019 21:54:34 +0900 Subject: Occupy match data * string.c (rb_str_split_m): occupy match data not to be modified during yielding the block. [Bug #16024] --- string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'string.c') 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); -- cgit v1.2.3