* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2016-07-13 05:26:00 +00:00
Родитель bebb62e01b
Коммит d8c3672b01
3 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,17 @@
Wed Jul 13 14:22:50 2016 Koichi Sasada <ko1@atdot.net>
* 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 <ko1@atdot.net>
* vm_method.c (method_entry_get_without_cache): check

3
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");
}

Просмотреть файл

@ -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