From f811e0126639c3cc14c285f2e2093d0df1b556af Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 14 Mar 2015 13:46:44 +0100 Subject: Fix a bug: malloc() with wrong size --- src/common/libalgo/hashtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/libalgo/hashtbl.c b/src/common/libalgo/hashtbl.c index 6fb5b60..0284d75 100644 --- a/src/common/libalgo/hashtbl.c +++ b/src/common/libalgo/hashtbl.c @@ -67,7 +67,7 @@ void hashtbl_check_size(hashtbl_t *ht) { if (4 * ht->nitems < ht->size) nsize = ht->size / 2; if (4 * ht->nitems > 3 * ht->size) nsize = ht->size * 2; - if (nsize != 0) { + if (nsize != 0 && nsize >= DEFAULT_HT_INIT_SIZE) { hashtbl_item_t **nitems = (hashtbl_item_t**)malloc(nsize * sizeof(hashtbl_item_t*)); if (nitems == 0) return; // if we can't realloc, too bad, we just lose space/efficienty -- cgit v1.2.3