aboutsummaryrefslogtreecommitdiff
path: root/src/common/libalgo/hashtbl.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-14 13:46:44 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-14 13:46:44 +0100
commitf811e0126639c3cc14c285f2e2093d0df1b556af (patch)
tree170ac684774303ddddda1e33bb0bcf3559a0b6e8 /src/common/libalgo/hashtbl.c
parentdabd2355f355abd7d1d58641f6cc496adb1482d1 (diff)
downloadkogata-f811e0126639c3cc14c285f2e2093d0df1b556af.tar.gz
kogata-f811e0126639c3cc14c285f2e2093d0df1b556af.zip
Fix a bug: malloc() with wrong size
Diffstat (limited to 'src/common/libalgo/hashtbl.c')
-rw-r--r--src/common/libalgo/hashtbl.c2
1 files changed, 1 insertions, 1 deletions
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