Check whether internal khash is initialized in Hash#compact!

This commit is contained in:
Clayton Smith
2017-08-17 12:13:41 -04:00
parent 0789ec71e0
commit 5dc688fb12
+1
View File
@@ -52,6 +52,7 @@ hash_compact_bang(mrb_state *mrb, mrb_value hash)
khash_t(ht) *h = RHASH_TBL(hash);
mrb_int n = -1;
if (!h) return mrb_nil_value();
for (k = kh_begin(h); k != kh_end(h); k++) {
if (kh_exist(h, k)) {
mrb_value val = kh_value(h, k).v;