Commit 11c3ad99 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3781 from clayton-shopify/fix-hash-compact-bang

Check whether internal khash is initialized in Hash#compact!
parents f229ed91 5dc688fb
...@@ -52,6 +52,7 @@ hash_compact_bang(mrb_state *mrb, mrb_value hash) ...@@ -52,6 +52,7 @@ hash_compact_bang(mrb_state *mrb, mrb_value hash)
khash_t(ht) *h = RHASH_TBL(hash); khash_t(ht) *h = RHASH_TBL(hash);
mrb_int n = -1; mrb_int n = -1;
if (!h) return mrb_nil_value();
for (k = kh_begin(h); k != kh_end(h); k++) { for (k = kh_begin(h); k != kh_end(h); k++) {
if (kh_exist(h, k)) { if (kh_exist(h, k)) {
mrb_value val = kh_value(h, k).v; mrb_value val = kh_value(h, k).v;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment