aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-10-12 22:43:34 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-10-12 22:44:23 +0900
commitebc2198d9f0292fee97e623b5e2a545fccb91d2a (patch)
tree90c28d2c0c44871c4f1bf9360f111a5efbae71e0 /re.c
parent7ebf9da78830cd13895a38809b0c6f1fc6797620 (diff)
downloadruby-ebc2198d9f0292fee97e623b5e2a545fccb91d2a.tar.gz
re.c (match_set_string): add a check for memory allocation
Found by Coverity Scan
Diffstat (limited to 're.c')
-rw-r--r--re.c3
1 files changed, 2 insertions, 1 deletions
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);