From c213b29d14aaf2f4523d638abc762eaaa873cf83 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 21 Mar 2015 08:58:04 -0700 Subject: [PATCH] Add xallocarray() helper macro Uses reallocarray to perform integer overflow detection when allocating an array, using NULL as the previous pointer to force a new allocation. Signed-off-by: Alan Coopersmith Reviewed-by: Matt Turner --- include/os.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/os.h b/include/os.h index ffa5f3923..263374185 100644 --- a/include/os.h +++ b/include/os.h @@ -74,6 +74,8 @@ typedef struct _NewClientRec *NewClientPtr; #define xstrdup(s) Xstrdup(s) #define xnfstrdup(s) XNFstrdup(s) + +#define xallocarray(num, size) reallocarray(NULL, (num), (size)) #endif #include