Skip to content

Commit

Permalink
fixed Regexp.quote
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentisambart committed Aug 4, 2009
1 parent 2d1c0a2 commit 6a41d99
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions re.c
Expand Up @@ -3118,7 +3118,7 @@ rb_reg_quote(VALUE str)
char *t_beg;

meta_found:
t_beg = (char *)alloca(RSTRING_LEN(str) * 2);
t_beg = (char *)alloca(RSTRING_LEN(str) * 2 + 1);
t = t_beg;
/* copy upto metacharacter */
memcpy(t, RSTRING_PTR(str), s - RSTRING_PTR(str));
Expand Down Expand Up @@ -3163,8 +3163,10 @@ rb_reg_quote(VALUE str)
}
*t++ = c;
}
// rb_str_new wants a NULL-terminated string
*t = 0;

return rb_str_new(t, t - t_beg);
return rb_str_new(t_beg, t - t_beg);
}


Expand Down

0 comments on commit 6a41d99

Please sign in to comment.