summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi
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 /spec/ruby/optional/capi
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 'spec/ruby/optional/capi')
-rw-r--r--spec/ruby/optional/capi/encoding_spec.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/spec/ruby/optional/capi/encoding_spec.rb b/spec/ruby/optional/capi/encoding_spec.rb
index 857e421ddb..b74a360760 100644
--- a/spec/ruby/optional/capi/encoding_spec.rb
+++ b/spec/ruby/optional/capi/encoding_spec.rb
@@ -312,7 +312,7 @@ describe "C-API Encoding function" do
end
it "sets the encoding of a Regexp to that of the second argument" do
- @s.rb_enc_copy(/regexp/, @obj).encoding.should == Encoding::US_ASCII
+ @s.rb_enc_copy(/regexp/.dup, @obj).encoding.should == Encoding::US_ASCII
end
end
@@ -363,7 +363,7 @@ describe "C-API Encoding function" do
end
it "sets the encoding of a Regexp to the encoding" do
- @s.rb_enc_associate(/regexp/, "BINARY").encoding.should == Encoding::BINARY
+ @s.rb_enc_associate(/regexp/.dup, "BINARY").encoding.should == Encoding::BINARY
end
it "sets the encoding of a String to a default when the encoding is NULL" do
@@ -380,7 +380,7 @@ describe "C-API Encoding function" do
it "sets the encoding of a Regexp to the encoding" do
index = @s.rb_enc_find_index("UTF-8")
- enc = @s.rb_enc_associate_index(/regexp/, index).encoding
+ enc = @s.rb_enc_associate_index(/regexp/.dup, index).encoding
enc.should == Encoding::UTF_8
end