diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-01-22 10:29:09 -0500 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-01-22 11:12:38 -0500 |
| commit | d68aaa66726b8fe929709521844e46dc20d61d08 (patch) | |
| tree | 8fda26e0166f28f6ad0700b17fbb8e26864c53c6 | |
| parent | 580429d27ce320b1615a03878d1fa8e2df6b80e2 (diff) | |
[PRISM] Freeze regex literals in iseqs
| -rw-r--r-- | prism_compile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c index a9f441e35c..9ec9e524e0 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -317,7 +317,10 @@ pm_new_regex(pm_regular_expression_node_t * cast, const pm_parser_t * parser) { VALUE regex_str = parse_string(&cast->unescaped, parser); rb_encoding * enc = pm_reg_enc(cast, parser); - return rb_enc_reg_new(RSTRING_PTR(regex_str), RSTRING_LEN(regex_str), enc, pm_reg_flags((const pm_node_t *)cast)); + VALUE regex = rb_enc_reg_new(RSTRING_PTR(regex_str), RSTRING_LEN(regex_str), enc, pm_reg_flags((const pm_node_t *)cast)); + rb_obj_freeze(regex); + + return regex; } /** |
