From 5ea678af50a664b1d83a3fef3d27d3ab4e48a5d9 Mon Sep 17 00:00:00 2001 From: tidwall Date: Mon, 22 Mar 2021 13:20:46 -0700 Subject: [PATCH] Fix overflow regression This commit fixes a regression introduced in c039c88 (v0.3.1) which causes a heap-buffer-overflow during hashmap_free. fixes #10 --- hashmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashmap.c b/hashmap.c index 5d217f2..d51d976 100644 --- a/hashmap.c +++ b/hashmap.c @@ -104,7 +104,7 @@ struct hashmap *hashmap_new(size_t elsize, size_t cap, bucketsz++; } // hashmap + spare + edata - size_t size = sizeof(struct hashmap)+bucketsz+elsize; + size_t size = sizeof(struct hashmap)+bucketsz*2; struct hashmap *map = hmmalloc(size); if (!map) { return NULL;