[前][次][番号順一覧][スレッド一覧]

ruby-changes:58237

From: Nobuyoshi <ko1@a...>
Date: Mon, 14 Oct 2019 15:28:58 +0900 (JST)
Subject: [ruby-changes:58237] 3e763883ea (master): Fixed overflow at onig_region_set

https://git.ruby-lang.org/ruby.git/commit/?id=3e763883ea

From 3e763883eab8435c6ebf9427b9bc49b95a1c7175 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 14 Oct 2019 15:10:33 +0900
Subject: 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.

diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 99d6992..84bf884 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -499,13 +499,17 @@ match_target(struct strscanner *p) https://github.com/ruby/ruby/blob/trunk/ext/strscan/strscan.c#L499
 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;
     }
 }
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]