diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-15 17:08:56 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-12-15 19:01:40 -0500 |
commit | 4c6c65e70cbe1e6b4b409ba18b71b2a8fb251d83 (patch) | |
tree | a1c7455f1a81bea1d40427440c32461008b7a524 /common/readline.c | |
parent | 9ad1e6b40f9589a5ab8242dd3b2e514b70d97799 (diff) |
Handle malloc failures from read_line
Diffstat (limited to 'common/readline.c')
-rw-r--r-- | common/readline.c | 3 |
1 files changed, 3 insertions, 0 deletions
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 <stdlib.h> #include <stdio.h> @@ -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; |