summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-08-06 23:12:44 +0200
committerTyge Løvset <[email protected]>2020-08-06 23:12:44 +0200
commit40d9a916f4d91e7562ec4c197f72ed661c84579e (patch)
tree2c77f6740405cdc6e81271845e6ea22c5b2eb6f7
parent11a54d769b65b31a8a5870157079db193195ea00 (diff)
downloadSTC-modified-40d9a916f4d91e7562ec4c197f72ed661c84579e.tar.gz
STC-modified-40d9a916f4d91e7562ec4c197f72ed661c84579e.zip
Fixed a serious free() bug in erase()
-rw-r--r--stc/cmap.h2
1 files changed, 1 insertions, 1 deletions
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; \
} \