summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-20 15:16:21 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-27 01:45:57 +0900
commit7ad56fd87b35abf4933e0146761df91e9ec9890a (patch)
tree36f7ec5b355f4ba7442d228fbb2a5a2f6f87be91 /re.c
parentf8d264fdfd4486062c2d526c37e05c4e5c73850d (diff)
freeze dynamic regexp literals
Regexp literals are frozen, and also dynamically comppiled Regexp literals (/#{expr}/) are frozen.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3676
Diffstat (limited to 're.c')
-rw-r--r--re.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/re.c b/re.c
index 020ba7b6d6..55b39bfdea 100644
--- a/re.c
+++ b/re.c
@@ -2944,7 +2944,9 @@ rb_reg_init_str_enc(VALUE re, VALUE s, rb_encoding *enc, int options)
MJIT_FUNC_EXPORTED VALUE
rb_reg_new_ary(VALUE ary, int opt)
{
- return rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
+ VALUE re = rb_reg_new_str(rb_reg_preprocess_dregexp(ary, opt), opt);
+ rb_obj_freeze(re);
+ return re;
}
VALUE