From 637eba26cb0882a8a042dbeca34bb66bee28b2e4 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 30 Apr 2022 18:13:17 -0700 Subject: [PATCH] cgraph: fix incorrect 'gv_recalloc' assertion The assertion here was claiming that overflow _did_ occur when computing the extent of the previous allocation rather than the reverse. --- lib/cgraph/alloc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cgraph/alloc.h b/lib/cgraph/alloc.h index 153b40f8c..7efbd7ea0 100644 --- a/lib/cgraph/alloc.h +++ b/lib/cgraph/alloc.h @@ -55,8 +55,7 @@ static inline void *gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size) { assert(size > 0 && "attempt to allocate array of 0-sized elements"); - assert(SIZE_MAX / size <= old_nmemb && - "claimed previous extent is too large"); + assert(old_nmemb < SIZE_MAX / size && "claimed previous extent is too large"); // will multiplication overflow? if (UNLIKELY(SIZE_MAX / size > new_nmemb)) { -- 2.40.0