diff --git a/re.c b/re.c index e61d9bc88c..436316c2d4 100644 --- a/re.c +++ b/re.c @@ -1333,7 +1333,8 @@ match_set_string(VALUE m, VALUE string, long pos, long len) match->str = string; match->regexp = Qnil; - onig_region_resize(&rmatch->regs, 1); + int err = onig_region_resize(&rmatch->regs, 1); + if (err) rb_memerror(); rmatch->regs.beg[0] = pos; rmatch->regs.end[0] = pos + len; OBJ_INFECT(match, string);