summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-19 21:20:33 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-19 21:20:33 +0000
commitfb03eb91fea8de00e78bdccfd00265a9ddd27538 (patch)
treeddbbf0aff798b8fd929715ebdc02ab8697372873 /hash.c
parent2fe13f62efe400736bb078cafcebba5f5ba7b83b (diff)
* hash.c (initialize_copy): unset the default proc if there isn't one
for the target hash, call to_hash, check frozen status. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/hash.c b/hash.c
index bf9dbd5467..1ddf23aea2 100644
--- a/hash.c
+++ b/hash.c
@@ -1185,6 +1185,9 @@ replace_i(VALUE key, VALUE val, VALUE hash)
static VALUE
rb_hash_initialize_copy(VALUE hash, VALUE hash2)
{
+ rb_hash_modify_check(hash);
+ hash2 = to_hash(hash2);
+
Check_Type(hash2, T_HASH);
if (!RHASH_EMPTY_P(hash2)) {
@@ -1195,6 +1198,9 @@ rb_hash_initialize_copy(VALUE hash, VALUE hash2)
if (FL_TEST(hash2, HASH_PROC_DEFAULT)) {
FL_SET(hash, HASH_PROC_DEFAULT);
}
+ else {
+ FL_UNSET(hash, HASH_PROC_DEFAULT);
+ }
RHASH_IFNONE(hash) = RHASH_IFNONE(hash2);
return hash;