diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-20 06:44:50 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-20 06:44:50 +0000 |
commit | ec7b1e475b1f8cb3ca775fec27227c6761d3b203 (patch) | |
tree | e9076717079404af996b46dce24cded888dfc0b6 /spec/mspec | |
parent | f89238ec0d689f3989c55c4716da500b8c898900 (diff) | |
download | ruby-ec7b1e475b1f8cb3ca775fec27227c6761d3b203.tar.gz |
Freeze hash literals embedded in duphash instructions
Previously, these hash literals were not frozen, and thus could be
modified by ObjectSpace, resulting in undesired behavior. Example:
```ruby
require 'objspace'
def a(b={0=>1,1=>4,2=>17})
b
end
p a
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
```
It may be desirable to hide such hashes from ObjectSpace, since
they are internal, but I'm not sure how to do that.
From: Jeremy Evans <code@jeremyevans.net>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec')
0 files changed, 0 insertions, 0 deletions