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 <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Alan Coopersmith 2015-03-21 08:58:04 -07:00
parent 0887c9463f
commit c213b29d14

View File

@ -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 <stdio.h>