summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-11-27 11:40:18 +0000
committerYusuke Endoh <mame@ruby-lang.org>2020-01-15 10:38:47 +0900
commit98ef38ada43338c073f50a0093196f0356284625 (patch)
tree1e7bdf0b54f4745501b9f3aed8ac44132ab6d25b /re.c
parent07aef4c99ac4be3073f8b15ebdfa324a7f94f5e3 (diff)
Freeze Regexp literals
[Feature #8948] [Feature #16377] Since Regexp literals always reference the same instance, allowing to mutate them can lead to state leak.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2705
Diffstat (limited to 're.c')
-rw-r--r--re.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/re.c b/re.c
index 56b5144f9f..3efd540359 100644
--- a/re.c
+++ b/re.c
@@ -2967,6 +2967,7 @@ rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
return Qnil;
}
FL_SET(re, REG_LITERAL);
+ rb_obj_freeze(re);
return re;
}