Marshal.load: also freeze extended objects
[Bug #19427] The `proc` wouldn't be called either, that fixes both.
This commit is contained in:
parent
bc6e587e86
commit
7ddcee5928
Notes:
git
2023-02-13 16:08:46 +00:00
@ -1865,6 +1865,7 @@ r_object_for(struct load_arg *arg, bool partial, int *ivp, VALUE extmod, int typ
|
|||||||
rb_extend_object(v, m);
|
rb_extend_object(v, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
v = r_leave(v, arg, partial);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -69,6 +69,18 @@ describe :marshal_load, shared: true do
|
|||||||
Object.should_not.frozen?
|
Object.should_not.frozen?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ruby_bug "#19427", ""..."3.3" do
|
||||||
|
it "does freeze extended objects" do
|
||||||
|
object = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x00", freeze: true)
|
||||||
|
object.should.frozen?
|
||||||
|
end
|
||||||
|
|
||||||
|
it "does freeze extended objects with instance variables" do
|
||||||
|
object = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x06:\n@ivarT", freeze: true)
|
||||||
|
object.should.frozen?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "when called with a proc" do
|
describe "when called with a proc" do
|
||||||
it "call the proc with frozen objects" do
|
it "call the proc with frozen objects" do
|
||||||
arr = []
|
arr = []
|
||||||
@ -132,6 +144,14 @@ describe :marshal_load, shared: true do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ruby_bug "#19427", ""..."3.3" do
|
||||||
|
it "call the proc with extended objects" do
|
||||||
|
objs = []
|
||||||
|
obj = Marshal.load("\x04\be:\x0FEnumerableo:\vObject\x00", Proc.new { |o| objs << o; o })
|
||||||
|
objs.should == [obj]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "returns the value of the proc" do
|
it "returns the value of the proc" do
|
||||||
Marshal.send(@method, Marshal.dump([1,2]), proc { [3,4] }).should == [3,4]
|
Marshal.send(@method, Marshal.dump([1,2]), proc { [3,4] }).should == [3,4]
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user