diff options
Diffstat (limited to 'ext/strscan/strscan.c')
-rw-r--r-- | ext/strscan/strscan.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |