From f8e0e1647eb80d2b6e84b1ecceaaf86649719a96 Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 17 Oct 2013 08:44:26 +0000 Subject: * vm_insnhelper.c (vm_call_method): set ci->me to 0 when the original method of a refined method is undef to avoid SEGV. * vm_method.c (rb_method_entry_without_refinements): return 0 when the original method of a refined method is undef to avoid SEGV. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_refinement.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'test/ruby/test_refinement.rb') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 31234ed00b..98dae15f00 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1059,6 +1059,54 @@ class TestRefinement < Test::Unit::TestCase INPUT end + def test_refine_undefed_method_and_call + assert_in_out_err([], <<-INPUT, ["NoMethodError"], []) + class Foo + def foo + end + + undef foo + end + + module FooExt + refine Foo do + def foo + end + end + end + + begin + Foo.new.foo + rescue => e + p e.class + end + INPUT + end + + def test_refine_undefed_method_and_send + assert_in_out_err([], <<-INPUT, ["NoMethodError"], []) + class Foo + def foo + end + + undef foo + end + + module FooExt + refine Foo do + def foo + end + end + end + + begin + Foo.new.send(:foo) + rescue => e + p e.class + end + INPUT + end + private def eval_using(mod, s) -- cgit v1.2.3