summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorZack Deveau <zack.ref@gmail.com>2024-04-19 16:53:05 -0400
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-20 10:41:01 +0900
commit9555a997aca422214c0e4d5a0fcf56210959a6f5 (patch)
tree7e7bc3961463627233117bcb4916949178226f98 /test/ruby
parent23be6599a20a0fd6bbf650816d163f9adfb82009 (diff)
ensure ibf_load_setup is only passed String params
In cases where RubyVM::InstructionSequence.load_from_binary() is passed a param other than a String, we attempt to call the RSTRING_LENINT macro on it which can cause a segfault. ex: ``` var_0 = 0 RubyVM::InstructionSequence.load_from_binary(var_0) ``` This commit adds a type check to raise unless we are provided a String.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_iseq.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index dbf91fe8c9..d2a39e673f 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -850,4 +850,11 @@ class TestISeq < Test::Unit::TestCase
RubyVM::InstructionSequence.compile_prism(Object.new)
end
end
+
+ def test_load_from_binary_only_accepts_string_param
+ assert_raise(TypeError) do
+ var_0 = 0
+ RubyVM::InstructionSequence.load_from_binary(var_0)
+ end
+ end
end