From 007986974a64bec4f6839f32c93a5d4736f1e146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= Date: Fri, 31 Jan 2014 17:30:27 +0200 Subject: [PATCH] config: Make config_alloc() no longer crash if allocation fails --- src/config.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/config.c b/src/config.c index 92b9de0b..049de61d 100644 --- a/src/config.c +++ b/src/config.c @@ -35,6 +35,11 @@ config *config_alloc() { config *cfg = (config *)malloc(sizeof(config)); + if (!cfg) { + fprintf(stderr, "Failed to allocate a config object!\n"); + return cfg; + } + memset(cfg, 0, sizeof(config)); return cfg; }