[前][次][番号順一覧][スレッド一覧]

ruby-changes:63449

From: Koichi <ko1@a...>
Date: Tue, 27 Oct 2020 01:46:20 +0900 (JST)
Subject: [ruby-changes:63449] 7ad56fd87b (master): freeze dynamic regexp literals

https://git.ruby-lang.org/ruby.git/commit/?id=7ad56fd87b

From 7ad56fd87b35abf4933e0146761df91e9ec9890a Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Tue, 20 Oct 2020 15:16:21 +0900
Subject: freeze dynamic regexp literals

Regexp literals are frozen, and also dynamically comppiled Regexp
literals (/#{expr}/) are frozen.

diff --git a/re.c b/re.c
index 020ba7b..55b39bf 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) https://github.com/ruby/ruby/blob/trunk/re.c#L2944
 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
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index 0cba377..ea31804 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -125,6 +125,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L125
             filter = /\A(?=.*#{filter})(?!.*#{negative})/
           end
           if Regexp === filter
+            filter = filter.dup
             # bypass conversion in minitest
             def filter.=~(other)    # :nodoc:
               super unless Regexp === other
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]