summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-23 00:20:27 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-23 00:20:27 (GMT)
commita6f0ec21e9d07a7a10f5a2fe06728fdad5b4d1d6 (patch)
tree94d57d2c7b057a9f18f035b71ea0cc7b62c0caee /hash.c
parent3aa95e78467d64efe5b029fbae4c07eddd8ca057 (diff)
mark Hash keys correctly.
* hash.c (rb_hash_new_from_object): same as r58434. Newly created frozen objects are not referred from any roots/objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/hash.c b/hash.c
index c159bfc..ea31e08 100644
--- a/hash.c
+++ b/hash.c
@@ -643,10 +643,8 @@ hash_insert_raw(VALUE hash, st_table *tbl, VALUE key, VALUE val)
(st_data_t)key;
st_insert(tbl, k, v);
- if (hash != Qfalse) {
- RB_OBJ_WRITTEN(hash, Qundef, key);
- RB_OBJ_WRITTEN(hash, Qundef, val);
- }
+ RB_OBJ_WRITTEN(hash, Qundef, key);
+ RB_OBJ_WRITTEN(hash, Qundef, val);
}
static VALUE
@@ -695,6 +693,8 @@ rb_hash_new_from_object(VALUE klass, VALUE obj)
long i;
long len = RARRAY_LEN(tmp);
st_table *tbl = len ? st_init_table_with_size(&objhash, len) : NULL;
+ VALUE hv = hash_alloc_from_st(klass, tbl);;
+
for (i = 0; i < len; ++i) {
VALUE e = RARRAY_AREF(tmp, i);
VALUE v = rb_check_array_type(e);
@@ -721,10 +721,10 @@ rb_hash_new_from_object(VALUE klass, VALUE obj)
val = RARRAY_AREF(v, 1);
case 1:
key = RARRAY_AREF(v, 0);
- hash_insert_raw(Qfalse, tbl, key, val);
+ hash_insert_raw(hv, tbl, key, val);
}
}
- return hash_alloc_from_st(klass, tbl);
+ return hv;
}
rb_raise(rb_eArgError, "odd number of arguments for Hash");