From: Mathieu Desnoyers Date: Sat, 3 Sep 2011 15:42:30 +0000 (-0400) Subject: rculfhash: Check that init size is power of 2 X-Git-Tag: v0.7.0~43^2~188 X-Git-Url: https://git.lttng.org/?p=urcu.git;a=commitdiff_plain;h=8129be4e7b668906bdbb68c4d7c9fcb403ae977a rculfhash: Check that init size is power of 2 Signed-off-by: Mathieu Desnoyers --- 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;