diff options
-rw-r--r-- | compile.c | 10 | ||||
-rw-r--r-- | test/ruby/test_iseq.rb | 9 |
2 files changed, 13 insertions, 6 deletions
@@ -8773,7 +8773,15 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of rb_raise(rb_eRuntimeError, "path object size mismatch"); } path = rb_fstring(RARRAY_AREF(pathobj, 0)); - realpath = rb_fstring(RARRAY_AREF(pathobj, 1)); + realpath = RARRAY_AREF(pathobj, 1); + if (!NIL_P(realpath)) { + if (!RB_TYPE_P(realpath, T_STRING)) { + rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE + "(%x), path=%+"PRIsVALUE, + realpath, TYPE(realpath), path); + } + realpath = rb_fstring(realpath); + } } else { rb_raise(rb_eRuntimeError, "unexpected path object"); diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb index 4c811611ba..1a45778cc4 100644 --- a/test/ruby/test_iseq.rb +++ b/test/ruby/test_iseq.rb @@ -398,10 +398,9 @@ class TestISeq < Test::Unit::TestCase def test_to_binary_with_objects code = "[]"+100.times.map{|i|"<</#{i}/"}.join - bin = assert_nothing_raised { - RubyVM::InstructionSequence.compile(code).to_binary - } - # load_from_binary doesn't work now - assert_instance_of(String, bin) + iseq = RubyVM::InstructionSequence.compile(code) + bin = assert_nothing_raised {iseq.to_binary} + iseq2 = RubyVM::InstructionSequence.load_from_binary(bin) + assert_equal(iseq2.to_a, iseq.to_a) end end |