Skip to content
Browse files

get_string*: fix a memory leak

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information...
1 parent 02de772 commit bfe6897366a85b1d76be9528e41b5ee8bb3a570c @neuschaefer neuschaefer committed with Jul 19, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 bti.c
View
8 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';

0 comments on commit bfe6897

Please sign in to comment.
Something went wrong with that request. Please try again.