From 9e0a91d0640600f2dfd7fc1d5fae6667019c9ca5 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 4 Jan 2022 09:13:19 -0800 Subject: Don't segfault if Warning.warn is undefined Check that there is a method entry for the method before passing it to rb_method_entry_arity. Fixes [Bug #18458] --- test/ruby/test_exception.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 2985f75fd6..3be9b9aee0 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1192,6 +1192,14 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_empty warning end + def test_undef_Warning_warn + assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") + begin; + Warning.undef_method(:warn) + assert_raise(NoMethodError) { warn "" } + end; + end + def test_undefined_backtrace assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") begin; -- cgit v1.2.3