ruby-changes:58226
From: Yusuke <ko1@a...>
Date: Sat, 12 Oct 2019 22:44:41 +0900 (JST)
Subject: [ruby-changes:58226] ebc2198d9f (master): re.c (match_set_string): add a check for memory allocation
https://git.ruby-lang.org/ruby.git/commit/?id=ebc2198d9f From ebc2198d9f0292fee97e623b5e2a545fccb91d2a Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sat, 12 Oct 2019 22:43:34 +0900 Subject: re.c (match_set_string): add a check for memory allocation Found by Coverity Scan diff --git a/re.c b/re.c index e61d9bc..436316c 100644 --- a/re.c +++ b/re.c @@ -1333,7 +1333,8 @@ match_set_string(VALUE m, VALUE string, long pos, long len) https://github.com/ruby/ruby/blob/trunk/re.c#L1333 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); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/