From 1f019ceea1ed39286e6bccfb3ff936c22fe0f7c0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Jun 2016 17:19:10 +0200 Subject: Fix various memory management issues Consistently handle allocation failures. Some functions are changed to return bool or int instead of void to allow returning an error. Also fix a buffer size miscalculation in lua/uloop and use _exit() instead of exit() on errors after forking. Signed-off-by: Matthias Schiffer --- utils.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 8fd19f4..91dd71e 100644 --- a/utils.c +++ b/utils.c @@ -43,6 +43,8 @@ void *__calloc_a(size_t len, ...) va_end(ap1); ptr = calloc(1, alloc_len); + if (!ptr) + return NULL; alloc_len = 0; foreach_arg(ap, cur_addr, cur_len, &ret, len) { *cur_addr = &ptr[alloc_len]; -- cgit v1.2.3