summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--hash.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9801c367df..c954757318 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Oct 20 06:18:34 2012 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * hash.c (initialize_copy): unset the default proc if there isn't one
+ for the target hash, call to_hash, check frozen status.
+
Fri Oct 19 22:22:01 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm.c (rb_vm_jump_tag_but_local_jump): pass through thrown objects.
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;