aboutsummaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
Diffstat (limited to 're.c')
-rw-r--r--re.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/re.c b/re.c
index 8f4d14dfc9..1a01490e5b 100644
--- a/re.c
+++ b/re.c
@@ -1508,6 +1508,7 @@ static VALUE reg_cache;
VALUE
rb_reg_regcomp(VALUE str)
{
+ volatile VALUE save_str = str;
if (reg_cache && RREGEXP(reg_cache)->len == RSTRING_LEN(str)
&& case_cache == ruby_ignorecase
&& kcode_cache == reg_kcode
@@ -1516,7 +1517,7 @@ rb_reg_regcomp(VALUE str)
case_cache = ruby_ignorecase;
kcode_cache = reg_kcode;
- return reg_cache = rb_reg_new(RSTRING_PTR(str), RSTRING_LEN(str),
+ return reg_cache = rb_reg_new(RSTRING_PTR(save_str), RSTRING_LEN(save_str),
ruby_ignorecase);
}