diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-12-17 13:23:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-17 13:23:44 -0500 |
commit | f04ee0e68d885d7e1101cc88f9a9337202041f1f (patch) | |
tree | fa4dc296a5f1377867752d320ceef4e4b0178bbf /common/readline.c | |
parent | 6c0fc2093641868df28c4087902a040f7fae05d4 (diff) | |
parent | d859f825d3612492678f5cd6cc6dc1f2647929e1 (diff) |
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
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; |