diff options
author | Half-Shot <half-shot@molrams.com> | 2015-08-20 21:32:08 +0100 |
---|---|---|
committer | Half-Shot <half-shot@molrams.com> | 2015-08-20 21:32:08 +0100 |
commit | 5a9ba261bca4ca709ec7a14d2019b55d9ce06994 (patch) | |
tree | fe1a924cf8055b2b722566db6ab98295dcf08ce7 /sway/readline.c | |
parent | 2a62c5c7fb71fc815663281793ba6a89d2b246ed (diff) | |
parent | 1100335ea01ecd56df68568622580db14e72b6c7 (diff) |
Merge branch 'master' of https://github.com/SirCmpwn/sway
Diffstat (limited to 'sway/readline.c')
-rw-r--r-- | sway/readline.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sway/readline.c b/sway/readline.c index dfdc3fe8..e75b183f 100644 --- a/sway/readline.c +++ b/sway/readline.c @@ -17,18 +17,22 @@ char *read_line(FILE *file) { continue; } if (length == size) { - string = realloc(string, size *= 2); - if (!string) { + char *new_string = realloc(string, size *= 2); + if (!new_string) { + free(string); return NULL; } + string = new_string; } string[length++] = c; } if (length + 1 == size) { - string = realloc(string, length + 1); - if (!string) { + char *new_string = realloc(string, length + 1); + if (!new_string) { + free(string); return NULL; } + string = new_string; } string[length] = '\0'; return string; |