summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/variable.c b/src/variable.c
index 3dcdbf775..6503c8fb7 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -308,7 +308,10 @@ iv_put(mrb_state *mrb, iv_tbl *t, mrb_sym sym, mrb_value val)
khash_t(iv) *h = &t->h;
khiter_t k;
- k = kh_put(iv, mrb, h, sym);
+ k = kh_get(mt, mrb, h, sym);
+ if (k == kh_end(h)) {
+ k = kh_put(mt, mrb, h, sym);
+ }
kh_value(h, k) = val;
}