diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-10-14 15:10:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-10-14 15:10:56 +0900 |
commit | 3e763883eab8435c6ebf9427b9bc49b95a1c7175 (patch) | |
tree | dfbfc998a4a153728595926fb6111add81cc3241 /ext | |
parent | d0ed935d5bf8c3fce9800742a36e44fb7f63dda4 (diff) | |
download | ruby-3e763883eab8435c6ebf9427b9bc49b95a1c7175.tar.gz |
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.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/strscan/strscan.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index 99d6992601..84bf884a56 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -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; } } |