summaryrefslogtreecommitdiffhomepage
path: root/src/hash.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2018-10-12 19:00:45 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2018-10-12 19:00:45 +0900
commite5f160dc7ec4f5ae596a7129f368ccc06186c3ee (patch)
tree62bf5365e111208a94f573c7e009b79188217f9d /src/hash.c
parentab0f4db688248a27faba904a0b2bdc55ba9e5ac9 (diff)
downloadmruby-e5f160dc7ec4f5ae596a7129f368ccc06186c3ee.tar.gz
mruby-e5f160dc7ec4f5ae596a7129f368ccc06186c3ee.zip
Should not compare `undef` (deleted) key in hashes; fix #4136
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 325c7e66f..e1ceec489 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -402,7 +402,8 @@ sg_index_get(mrb_state *mrb, seglist *t, mrb_value key, mrb_value *vp)
size_t step = 0;
while (index->table[k]) {
- if (sg_hash_equal(mrb, t, key, index->table[k]->key)) {
+ mrb_value key2 = index->table[k]->key;
+ if (!mrb_undef_p(key2) && sg_hash_equal(mrb, t, key, key2)) {
if (vp) *vp = index->table[k]->val;
return TRUE;
}