From bfe6897366a85b1d76be9528e41b5ee8bb3a570c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 19 Jul 2011 16:06:56 +0200 Subject: [PATCH] get_string*: fix a memory leak Signed-off-by: Greg Kroah-Hartman --- bti.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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'; -- 2.39.5