Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get_string*: fix a memory leak

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information...
commit bfe6897366a85b1d76be9528e41b5ee8bb3a570c 1 parent 02de772
@neuschaefer neuschaefer authored committed
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';
Please sign in to comment.
Something went wrong with that request. Please try again.