From 3776e3a77bff3f3d7091e91aac2e1b6b3425b28d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 21 Apr 2020 13:33:25 +0200 Subject: [PATCH] fix #6189 --- src/include/gnunet_common.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 9e7c77786..fcc510ec9 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -1209,7 +1209,10 @@ GNUNET_is_zero_ (const void *a, * @param n number of elements in the array * @param type name of the struct or union, i.e. pass 'struct Foo'. */ -#define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof(type)) +#define GNUNET_new_array(n, type) ({ \ + GNUNET_assert (SIZE_MAX / sizeof (type) >= n); \ + (type *) GNUNET_malloc ((n) * sizeof(type)); \ + }) /** * @ingroup memory -- 2.25.1