Skip to content

Commit

Permalink
own the object by GC_RETAIN()
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jan 7, 2012
1 parent 0126708 commit 6ee4bbd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion re.c
Expand Up @@ -665,6 +665,7 @@ static void
reg_matcher_cleanup(rb_regexp_matcher_t *m)
{
if (m->pattern != NULL) {
GC_RELEASE(m->orig_str);
uregex_close(m->pattern);
m->pattern = NULL;
}
Expand Down Expand Up @@ -718,7 +719,8 @@ rb_reg_matcher_new(VALUE re, VALUE str)

matcher->pattern = match_pattern;
matcher->frozen_str = 0; // set lazily
GC_WB(&matcher->orig_str, str);
matcher->orig_str = str;
GC_RETAIN(matcher->orig_str);

// Apparently uregex_setText doesn't copy the given string, so we need
// to keep it around until we finally destroy the matcher object.
Expand Down

0 comments on commit 6ee4bbd

Please sign in to comment.