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 --- jshn.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'jshn.c') diff --git a/jshn.c b/jshn.c index e2d9022..4989099 100644 --- a/jshn.c +++ b/jshn.c @@ -338,6 +338,10 @@ int main(int argc, char **argv) for (i = 0; environ[i]; i++); vars = calloc(i, sizeof(*vars)); + if (!vars) { + fprintf(stderr, "%m\n"); + return -1; + } for (i = 0; environ[i]; i++) { char *c; -- cgit v1.2.3