From: Jonathan Neuschäfer Date: Tue, 19 Jul 2011 14:06:56 +0000 (+0200) Subject: get_string*: fix a memory leak X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/commitdiff_plain/bfe6897366a85b1d76be9528e41b5ee8bb3a570c?ds=sidebyside get_string*: fix a memory leak Signed-off-by: Greg Kroah-Hartman --- diff --git a/bti.c b/bti.c index db9cadc..6f77ddc 100644 --- a/bti.c +++ b/bti.c @@ -100,8 +100,10 @@ static char *get_string(const char *name) exit(1); if (name != NULL) fprintf(stdout, "%s", name); - if (!fgets(string, 999, stdin)) + if (!fgets(string, 999, stdin)) { + free(string); return NULL; + } temp = strchr(string, '\n'); if (temp) *temp = '\0'; @@ -835,8 +837,10 @@ static char *get_string_from_stdin(void) if (!string) return NULL; - if (!fgets(string, 999, stdin)) + if (!fgets(string, 999, stdin)) { + free(string); return NULL; + } temp = strchr(string, '\n'); if (temp) *temp = '\0';