1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

re.c (match_set_string): add a check for memory allocation

Found by Coverity Scan
This commit is contained in:
Yusuke Endoh 2019-10-12 22:43:34 +09:00
parent 7ebf9da788
commit ebc2198d9f

3
re.c
View file

@ -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);