Skip to content

Commit

Permalink
Hash#{clone, dup} will copy status of untrust.
Browse files Browse the repository at this point in the history
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

a = { 1 => 'one', 2 => 'two', 3 => 'three' }
a.untrust
a.taint
a.freeze

b = a.clone
assert_equal(a.untrusted?, b.untrusted?)
assert_equal(a.tainted?, b.tainted?)
assert_equal(a.frozen?, b.frozen?)

c = a.dup
assert_equal(a.untrusted?, c.untrusted?)
assert_equal(a.tainted?, c.tainted?)
assert_equal(false, c.frozen?)

puts :ok
}}}

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5306 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information
Watson1978 committed Mar 25, 2011
1 parent cf1bc99 commit 68162bf
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions hash.c
Expand Up @@ -168,9 +168,7 @@ rhash_dup(VALUE rcv, SEL sel)

VALUE dup = rhash_copy(rcv, klass);

if (OBJ_TAINTED(rcv)) {
OBJ_TAINT(dup);
}
OBJ_INFECT(dup, rcv);
return dup;
}

Expand All @@ -179,9 +177,7 @@ rhash_clone(VALUE rcv, SEL sel)
{
VALUE clone = rhash_copy(rcv, CLASS_OF(rcv));

if (OBJ_TAINTED(rcv)) {
OBJ_TAINT(clone);
}
OBJ_INFECT(clone, rcv);
if (OBJ_FROZEN(rcv)) {
OBJ_FREEZE(clone);
}
Expand Down

0 comments on commit 68162bf

Please sign in to comment.