From b3e1093572e6b84b41f3fc12f5a411b7ed6bd1c2 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sat, 30 Apr 2022 18:16:34 -0700 Subject: [PATCH] cgraph: fix overflow check in 'gv_recalloc' --- lib/cgraph/alloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cgraph/alloc.h b/lib/cgraph/alloc.h index 7efbd7ea0..2b25a1b37 100644 --- a/lib/cgraph/alloc.h +++ b/lib/cgraph/alloc.h @@ -58,7 +58,7 @@ static inline void *gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, assert(old_nmemb < SIZE_MAX / size && "claimed previous extent is too large"); // will multiplication overflow? - if (UNLIKELY(SIZE_MAX / size > new_nmemb)) { + if (UNLIKELY(new_nmemb > SIZE_MAX / size)) { fprintf(stderr, "integer overflow in dynamic memory reallocation\n"); graphviz_exit(EXIT_FAILURE); } -- 2.40.0