From: Matthew Fernandez Date: Sun, 1 May 2022 01:13:17 +0000 (-0700) Subject: cgraph: fix incorrect 'gv_recalloc' assertion X-Git-Tag: 4.0.0~45^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=637eba26cb0882a8a042dbeca34bb66bee28b2e4;p=graphviz 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. --- 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)) {