From fddf7ab78082c90a674fda8ba1bbcbdc719683b7 Mon Sep 17 00:00:00 2001 From: jiriks74 Date: Tue, 3 Dec 2024 14:20:43 +0100 Subject: [PATCH] fix(01): Fix memory leaks --- 01/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/01/src/main.c b/01/src/main.c index 165cafd..9602055 100644 --- a/01/src/main.c +++ b/01/src/main.c @@ -72,14 +72,14 @@ int main(int argc, char *argv[]) rewind(file); for (uint i = 0; i < lines; i++) { - char *buffer = NULL; - size_t bufferSize = 0; if (getline(&buffer, &bufferSize, file) == -1) break; sscanf(buffer, "%d %d", &array1[i], &array2[i]); } + free(buffer); + bufferSize = 0; fclose(file); qsort(array1, lines, sizeof(int), compareInt);