Actions
Bug #15440
closedFreeze hash literals embedded in duphash instructions
Description
Previously, these hash literals were not frozen, and thus could be
modified by ObjectSpace, resulting in undesired behavior. Example
(run with --disable-gems):
require 'objspace'
def a(b={0=>1,1=>4,2=>17})
b
end
p a
# => {0=>1, 1=>4, 2=>17}
ObjectSpace.each_object(Hash) do |a|
a[3] = 8 if a.class == Hash && a[0] == 1 && a[1] == 4 && a[2] == 17
end
p a
# => {0=>1, 1=>4, 2=>17, 3=>8}
Attached is a patch that freezes such hashes, so attempting to
modify the object will raise a FrozenError.
It may be desirable to hide such hashes from ObjectSpace, since
they are internal, but I'm not sure how to do that.
Files
Actions
Like0
Like0