Mon, 06 Mar 2017 16:22:42 +0100
safe one multiplication in overflow check for mempool_chcap()
ucx/mempool.c | file | annotate | diff | comparison | revisions |
--- a/ucx/mempool.c Mon Mar 06 16:09:42 2017 +0100 +++ b/ucx/mempool.c Mon Mar 06 16:22:42 2017 +0100 @@ -109,8 +109,8 @@ void *ucx_mempool_malloc(UcxMempool *pool, size_t n) { if (pool->ndata >= pool->size) { - if (pool->size*2 < pool->size /* overflow check */ - || ucx_mempool_chcap(pool, pool->size*2)) { + size_t newcap = pool->size*2; + if (newcap < pool->size || ucx_mempool_chcap(pool, newcap)) { return NULL; } }