mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: fix load_from_binary
* compile.c (ibf_load_iseq_each): realpath may be nil. follow up r59709. [fix https://github.com/Shopify/bootsnap/issues/132] From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d3c5746bbb
commit
ddf295a26f
2 changed files with 13 additions and 6 deletions
10
compile.c
10
compile.c
|
@ -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");
|
rb_raise(rb_eRuntimeError, "path object size mismatch");
|
||||||
}
|
}
|
||||||
path = rb_fstring(RARRAY_AREF(pathobj, 0));
|
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 {
|
else {
|
||||||
rb_raise(rb_eRuntimeError, "unexpected path object");
|
rb_raise(rb_eRuntimeError, "unexpected path object");
|
||||||
|
|
|
@ -398,10 +398,9 @@ class TestISeq < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_to_binary_with_objects
|
def test_to_binary_with_objects
|
||||||
code = "[]"+100.times.map{|i|"<</#{i}/"}.join
|
code = "[]"+100.times.map{|i|"<</#{i}/"}.join
|
||||||
bin = assert_nothing_raised {
|
iseq = RubyVM::InstructionSequence.compile(code)
|
||||||
RubyVM::InstructionSequence.compile(code).to_binary
|
bin = assert_nothing_raised {iseq.to_binary}
|
||||||
}
|
iseq2 = RubyVM::InstructionSequence.load_from_binary(bin)
|
||||||
# load_from_binary doesn't work now
|
assert_equal(iseq2.to_a, iseq.to_a)
|
||||||
assert_instance_of(String, bin)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue