summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2017-04-02 13:41:01 +0200
committerTobias Stoeckmann <tobias@stoeckmann.org>2017-04-02 13:41:01 +0200
commitb95c1ea6b2ff06ed01bee93a623141b2ab692470 (patch)
tree2ee4e272218f57a4cf65bc285481ff5ffd440ba5
parenta5e60401f9dce39f7f1bcf53ede508c63f5d2ad3 (diff)
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>
-rw-r--r--src/utils.c2
1 files changed, 1 insertions, 1 deletions
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);