[PATCH v2 05/17] Add xallocarray() helper macro

Alan Coopersmith alan.coopersmith at oracle.com
Thu Apr 16 18:49:13 PDT 2015

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 at oracle.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
 include/os.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/os.h b/include/os.h
index ffa5f39..2633741 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))
 #include <stdio.h>

More information about the xorg-devel mailing list