From b95c1ea6b2ff06ed01bee93a623141b2ab692470 Mon Sep 17 00:00:00 2001
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Sun, 2 Apr 2017 13:41:01 +0200
Subject: Check malloc return value for NULL.

If malloc cannot allocate enough memory, it could return NULL. This is
not necessarily true for default Linux settings, but can be provoked
there as well by adjusting proc entries. Other systems like the *BSD
ones definitely do this.

The function _emalloc exists for exactly this purpose, so use it instead
of calling malloc directly.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
---
 src/utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/utils.c b/src/utils.c
index bd189d3..7d30445 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -122,7 +122,7 @@ char *estrjoin(const char *separator, ...)
 			s = va_arg(args, char *);
 		}
 		va_end(args);
-		string = malloc(sizeof(char) * (len + 1));
+		string = _emalloc(sizeof(char) * (len + 1));
 
 		*string = 0;
 		va_start(args, separator);
-- 
cgit v1.2.3