summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-08 03:03:42 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-08 03:03:42 +0000
commit3dd248f13d47d708b2e3dcf92ab46937c033f67b (patch)
tree33c617ba94d7b26e76dca99ad699875e33dd20af /hash.c
parent8f77cfb308061ff49de0a47e82816c8dafa27963 (diff)
hash.c: fix WB miss issue in Hash#replace
* hash.c (rb_hash_replace): add a write barrier to fix GC mark miss on hashes using Hash#replace [Bug #9226] [ruby-core:58948] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/hash.c b/hash.c
index 1321b83191..7e18a4049a 100644
--- a/hash.c
+++ b/hash.c
@@ -1412,22 +1412,9 @@ rb_hash_replace(VALUE hash, VALUE hash2)
table2 = RHASH(hash2)->ntbl;
- if (RHASH_EMPTY_P(hash2)) {
- rb_hash_clear(hash);
- if (table2) hash_tbl(hash)->type = table2->type;
- return hash;
- }
-
- if (RHASH_ITER_LEV(hash) > 0) {
- rb_hash_clear(hash);
- hash_tbl(hash)->type = table2->type;
- rb_hash_foreach(hash2, replace_i, hash);
- }
- else {
- st_table *old_table = RHASH(hash)->ntbl;
- if (old_table) st_free_table(old_table);
- RHASH(hash)->ntbl = st_copy(table2);
- }
+ rb_hash_clear(hash);
+ hash_tbl(hash)->type = table2->type;
+ rb_hash_foreach(hash2, replace_i, hash);
return hash;
}