diff --git a/ChangeLog b/ChangeLog index 158df4f231..0ce0521314 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Wed Jul 13 14:22:50 2016 Koichi Sasada + + * iseq.c (Init_ISeq): undef ISeq.translate and ISeq.load_iseq + to prevent calling super classes' methods. + + Without this patch, you can write workaround like: + + class << RubyVM::InstructionSequence + def translate; end + undef translate + end + + * test/ruby/test_iseq.rb: add a test. + Wed Jul 13 14:16:03 2016 Koichi Sasada * vm_method.c (method_entry_get_without_cache): check diff --git a/iseq.c b/iseq.c index 28d35eb328..1c22fea74d 100644 --- a/iseq.c +++ b/iseq.c @@ -2462,4 +2462,7 @@ Init_ISeq(void) rb_define_singleton_method(rb_cISeq, "disasm", iseqw_s_disasm, 1); rb_define_singleton_method(rb_cISeq, "disassemble", iseqw_s_disasm, 1); rb_define_singleton_method(rb_cISeq, "of", iseqw_s_of, 1); + + rb_undef_method(CLASS_OF(rb_cISeq), "translate"); + rb_undef_method(CLASS_OF(rb_cISeq), "load_iseq"); } diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index a71ad565f7..dba714aa62 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -235,4 +235,14 @@ class TestISeq < Test::Unit::TestCase end assert_equal([m1, e1.message], [m2, e2.message], feature11951) end + + def test_translate_by_object + assert_separately([], <<-"end;") + class Object + def translate + end + end + assert_equal(0, eval("0")) + end; + end end