From 012c558127d329d2f846124958f7ab57bbaedc3b Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 1 Dec 2014 21:30:58 +0000 Subject: re.c: rb_reg_region_copy * re.c (rb_reg_region_copy): new function to try with GC if copy failed and return the error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/strscan/strscan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/strscan/strscan.c') diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index eb36cecc47..55d13d413b 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -251,8 +251,9 @@ strscan_init_copy(VALUE vself, VALUE vorig) self->str = orig->str; self->prev = orig->prev; self->curr = orig->curr; - onig_region_copy(&self->regs, &orig->regs); - if (!self->regs.allocated) rb_memerror(); + if (rb_reg_region_copy(&self->regs, &orig->regs)) + rb_memerror(); + RB_GC_GUARD(vorig); } return vself; -- cgit v1.2.3