From 46b0ace509d9ed013915e9ab8013c7c712e11395 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 24 Jun 2014 19:06:05 +0200 Subject: xmalloc: Add and use xcalloc Add a wrapper for calloc which checks for integer overflows in the calculation of the size to allocate. Use xcalloc to allocate an array of objects instead of calculating the size ourselves, which might cause an integer overflow. Signed-off-by: Tobias Klauser --- xmalloc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'xmalloc.h') diff --git a/xmalloc.h b/xmalloc.h index 952b827..2ad0372 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -7,6 +7,7 @@ #include "die.h" extern void *xmalloc(size_t size) __hidden; +extern void *xcalloc(size_t nmemb, size_t size) __hidden; extern void *xzmalloc(size_t size) __hidden; extern void *xmallocz(size_t size) __hidden; extern void *xmalloc_aligned(size_t size, size_t alignment) __hidden; -- cgit v1.2.3-54-g00ecf