Skip to content

Commit 3cda30d

Browse files
committed
Fix incorrect delete/re-insert in hashmap
Reported upstream at rui314/chibicc#135 TOMBSTONE entries cannot be reused, or subsequent probes can be incorrect.
1 parent 442affc commit 3cda30d

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/hashmap.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,8 @@ static HashEntry* get_or_insert_entry(HashMap* map, char* key, int keylen) {
9999
return ent;
100100
}
101101

102-
if (ent->key == TOMBSTONE) {
103-
ent->key = key;
104-
ent->keylen = keylen;
105-
return ent;
106-
}
102+
// It is tempting to allow a TOMBSTONE entry to be reused here, but they
103+
// cannot be, see: https://github.com/rui314/chibicc/issues/135.
107104

108105
if (ent->key == NULL) {
109106
ent->key = key;

0 commit comments

Comments
 (0)