From 4a28a8debd7182368052d990272f0b20dac688d1 Mon Sep 17 00:00:00 2001 From: anthraxx Date: Tue, 10 Jun 2014 23:14:29 +0200 Subject: [PATCH] some manual (unnecessery) free for good manner its not needed because OS is responsible to cleanup mem allocated by terminating process, but its still a good manner to explicitly free everything that gets allocated... yes this is "noise" if it terminates but neither does harm to feel being responsible to clean up everything ourselves. :) at least valgrind is silently happy :P :D --- challenge/challenge.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/challenge/challenge.c b/challenge/challenge.c index 938029b..05d3f12 100644 --- a/challenge/challenge.c +++ b/challenge/challenge.c @@ -14,15 +14,18 @@ int main(void) { /* read in password from standard input, exit on error. */ if (getline(&input_line, &input_size, stdin) == -1) { perror("Error"); + free(input_line); exit(EXIT_FAILURE); } /* compare password, print info, exit appropriately */ if (strcmp(input_line, password) == 0) { puts("Success!"); + free(input_line); exit(EXIT_SUCCESS); } else { puts("How about no?!"); + free(input_line); exit(EXIT_FAILURE); } }