From 4c6c65e70cbe1e6b4b409ba18b71b2a8fb251d83 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 15 Dec 2016 17:08:56 -0500 Subject: Handle malloc failures from read_line --- common/readline.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/readline.c b/common/readline.c index 5106172c..cc40a2cc 100644 --- a/common/readline.c +++ b/common/readline.c @@ -1,4 +1,5 @@ #include "readline.h" +#include "log.h" #include #include @@ -7,6 +8,7 @@ char *read_line(FILE *file) { char *string = malloc(size); char lastChar = '\0'; if (!string) { + sway_log(L_ERROR, "Unable to allocate memory for read_line"); return NULL; } while (1) { @@ -27,6 +29,7 @@ char *read_line(FILE *file) { char *new_string = realloc(string, size *= 2); if (!new_string) { free(string); + sway_log(L_ERROR, "Unable to allocate memory for read_line"); return NULL; } string = new_string; -- cgit v1.2.3-54-g00ecf