summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-21 11:02:10 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-21 11:02:10 +0000
commita7db63208833d69ba02ef5ad21d32017f148bc46 (patch)
tree97866e8b791add82f2787eb1e9a7b814d9e5a6d3 /hash.c
parent34f14888954ce96457fdb57c29061169c5fabd37 (diff)
mark created frozen strings.
* hash.c (rb_hash_new_from_values_with_klass): before this fix, only a st table are filled with passed values. However, newly created frozen strings are not marked correctly only reference from st table. This patch marks such created frozen strings by Hash object which refers to the st table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 45abacc861..b11b382bf1 100644
--- a/hash.c
+++ b/hash.c
@@ -639,8 +639,8 @@ hash_insert_raw(st_table *tbl, VALUE key, VALUE val)
{
st_data_t v = (st_data_t)val;
st_data_t k = (rb_obj_class(key) == rb_cString) ?
- (st_data_t)rb_str_new_frozen(key) :
- (st_data_t)key;
+ (st_data_t)rb_str_new_frozen(key) :
+ (st_data_t)key;
return st_insert(tbl, k, v);
}
@@ -650,19 +650,22 @@ rb_hash_new_from_values_with_klass(long argc, const VALUE *argv, VALUE klass)
{
long i;
st_table *t;
+ VALUE v;
if (argc % 2) {
rb_raise(rb_eArgError, "odd number of arguments for Hash");
}
t = st_init_table_with_size(&objhash, argc / 2);
+ v = hash_alloc_from_st(klass, t);
+
for (i = 0; i < argc; /* */) {
VALUE key = argv[i++];
VALUE val = argv[i++];
hash_insert_raw(t, key, val);
}
- return hash_alloc_from_st(klass, t);
+ return v;
}
VALUE