Skip to content

Commit

Permalink
Fix incorrect delete/re-insert in hashmap
Browse files Browse the repository at this point in the history
Reported upstream at rui314/chibicc#135

TOMBSTONE entries cannot be reused, or subsequent probes can be
incorrect.
  • Loading branch information
sgraham committed Oct 30, 2023
1 parent 442affc commit 3cda30d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/hashmap.c
Expand Up @@ -99,11 +99,8 @@ static HashEntry* get_or_insert_entry(HashMap* map, char* key, int keylen) {
return ent;
}

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

if (ent->key == NULL) {
ent->key = key;
Expand Down

0 comments on commit 3cda30d

Please sign in to comment.