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

Fixed overflow at onig_region_set

To get rid of a bug of `onig_region_set` which takes `int`s
instead of `OnigPosition`s, set elements of `beg` and `end`
members directly, for the time being.
This commit is contained in:
Nobuyoshi Nakada 2019-10-14 15:10:33 +09:00
parent d0ed935d5b
commit 3e763883ea
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -499,13 +499,17 @@ match_target(struct strscanner *p)
static inline void
set_registers(struct strscanner *p, size_t length)
{
onig_region_clear(&(p->regs));
const int at = 0;
OnigRegion *regs = &(p->regs);
onig_region_clear(regs);
if (onig_region_set(regs, at, 0, 0)) return;
if (p->fixed_anchor_p) {
onig_region_set(&(p->regs), 0, p->curr, p->curr + length);
regs->beg[at] = p->curr;
regs->end[at] = p->curr + length;
}
else
{
onig_region_set(&(p->regs), 0, 0, length);
regs->end[at] = length;
}
}