From 40d9a916f4d91e7562ec4c197f72ed661c84579e Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 6 Aug 2020 23:12:44 +0200 Subject: Fixed a serious free() bug in erase() --- stc/cmap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stc/cmap.h b/stc/cmap.h index e0a938ff..e11f243b 100644 --- a/stc/cmap.h +++ b/stc/cmap.h @@ -336,6 +336,7 @@ ctype##_##tag##_erase_entry(ctype##_##tag* self, ctype##_##tag##_entry_t* entry) ctype##_##tag##_rawkey_t r; \ if (! hashx[i]) \ return false; \ + ctype##_##tag##_entry_destroy(&slot[i]); \ do { /* deletion from hash table without tombstone */ \ if (++j == cap) j = 0; /* ++j; j %= cap; is slow */ \ if (! hashx[j]) \ @@ -346,7 +347,6 @@ ctype##_##tag##_erase_entry(ctype##_##tag* self, ctype##_##tag##_entry_t* entry) slot[i] = slot[j], hashx[i] = hashx[j], i = j; \ } while (true); \ hashx[i] = 0; \ - ctype##_##tag##_entry_destroy(&slot[i]); \ --self->size; \ return true; \ } \ -- cgit v1.2.3