From 8129be4e7b668906bdbb68c4d7c9fcb403ae977a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 3 Sep 2011 11:42:30 -0400 Subject: [PATCH] rculfhash: Check that init size is power of 2 Signed-off-by: Mathieu Desnoyers --- rculfhash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rculfhash.c b/rculfhash.c index 9aeb3e7..1720afb 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -621,6 +621,9 @@ struct cds_lfht *cds_lfht_new(cds_lfht_hash_fct hash_fct, struct cds_lfht *ht; unsigned long order; + /* init_size must be power of two */ + if (init_size & (init_size - 1)) + return NULL; ht = calloc(1, sizeof(struct cds_lfht)); ht->hash_fct = hash_fct; ht->compare_fct = compare_fct; -- 2.34.1