diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-27 21:54:34 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-07-27 21:54:34 +0900 |
commit | f1b76ea63ce40670071a857f408a4747c571f1e9 (patch) | |
tree | 941d10f573698fca4cefb737bdd09b12e6081128 /string.c | |
parent | e3b613a66986306950fc69d426d947a349b9fc8b (diff) | |
download | ruby-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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); |