From 33354b892112fcb16128b002570a9da14959bd65 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 2 Feb 2023 17:10:08 +0100 Subject: [PATCH] implemented why2_clean_memory in why2_check_version --- src/core/lib/utils/misc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/lib/utils/misc.c b/src/core/lib/utils/misc.c index 5a150c9..f90a34b 100644 --- a/src/core/lib/utils/misc.c +++ b/src/core/lib/utils/misc.c @@ -92,6 +92,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) { if (why2_get_flags().noCheck) return WHY2_SUCCESS; + why2_set_memory_identifier("version_check"); + //FILE-CHECK VARIABLES int notFoundBuffer = 0; @@ -118,6 +120,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) if (notFoundBuffer == WHY2_NOT_FOUND_TRIES) { if (!why2_get_flags().why2_no_output) fprintf(stderr, "%s'%s' not found! Exiting...\n", WHY2_CLEAR_SCREEN, WHY2_VERSIONS_NAME); + + why2_clean_memory("version_check"); return WHY2_DOWNLOAD_FAILED; } @@ -153,8 +157,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) //WAIT FOR 5 SECONDS sleep(5); - why2_free(buffer); fclose(fileBuffer); + why2_clean_memory("version_check"); return WHY2_SUCCESS; } @@ -174,6 +178,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) if (getuid() != 0) { if (!why2_get_flags().why2_no_output) fprintf(stderr, "You need to be root to update!\t[I DO NOT RECOMMEND USING THIS]\n"); + + why2_clean_memory("version_check"); return WHY2_WHY2_UPDATE_FAILED; } @@ -202,6 +208,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) if (exitCode != 0) { if (!why2_get_flags().why2_no_output) fprintf(stderr, "Updating failed! (cloning)\n"); + + why2_clean_memory("version_check"); return WHY2_WHY2_UPDATE_FAILED; } @@ -219,10 +227,12 @@ enum WHY2_EXIT_CODES why2_check_version(void) if (installCode != 0) { if (!why2_get_flags().why2_no_output) fprintf(stderr, "Updating failed! (installing)\n"); + + why2_clean_memory("version_check"); return WHY2_WHY2_UPDATE_FAILED; } - goto deallocation; //GREAT WHY2_SUCCESS! + goto deallocation; //GREAT SUCCESS! } //COUNT WHY2_VERSIONS BEHIND @@ -267,6 +277,8 @@ enum WHY2_EXIT_CODES why2_check_version(void) json_object_put(parsedJson); //THIS FREES EVERY json_object - AT LEAST JSON-C'S DOCUMENTATION SAYS THAT why2_free(buffer); + why2_reset_memory_identifier(); + return WHY2_SUCCESS; }