summaryrefslogtreecommitdiff
path: root/ext/strscan
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-01 21:30:58 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-01 21:30:58 (GMT)
commit012c558127d329d2f846124958f7ab57bbaedc3b (patch)
tree7c58ff528c9b08835e3dcfbbb47b6dd19a7ec9fd /ext/strscan
parent4ea50d7aea9e84be4b2ea206c939bffa903bd509 (diff)
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
Diffstat (limited to 'ext/strscan')
-rw-r--r--ext/strscan/strscan.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index eb36cec..55d13d4 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;