summaryrefslogtreecommitdiffhomepage
path: root/src/hash.c
diff options
context:
space:
mode:
authorClayton Smith <[email protected]>2017-03-28 16:31:19 -0400
committerClayton Smith <[email protected]>2017-03-28 16:31:19 -0400
commita6e25f73a05bb0292c0c9f10b77c5cdaf260e4d0 (patch)
tree6395c4e6dd2044a9b1ce955755c2101554ec1f58 /src/hash.c
parent5ec051fc34a380687cbca463228131b013aa8db2 (diff)
downloadmruby-a6e25f73a05bb0292c0c9f10b77c5cdaf260e4d0.tar.gz
mruby-a6e25f73a05bb0292c0c9f10b77c5cdaf260e4d0.zip
Renumber hash keys during dup since there may be duplicates.
Diffstat (limited to 'src/hash.c')
-rw-r--r--src/hash.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/hash.c b/src/hash.c
index d15faa206..3a7aea245 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -246,7 +246,8 @@ mrb_hash_dup(mrb_state *mrb, mrb_value hash)
int ai = mrb_gc_arena_save(mrb);
ret_k = kh_put(ht, mrb, ret_h, KEY(kh_key(h, k)));
mrb_gc_arena_restore(mrb, ai);
- kh_val(ret_h, ret_k) = kh_val(h, k);
+ kh_val(ret_h, ret_k).v = kh_val(h, k).v;
+ kh_val(ret_h, ret_k).n = kh_size(ret_h)-1;
}
}
}