From fd13d973bad21e8d75b6ef5e61a0feb22e09990d Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 25 Sep 2014 19:32:28 +0200 Subject: [PATCH] fix memory leak in list command --- mfshell/commands/list.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mfshell/commands/list.c b/mfshell/commands/list.c index 922d756..0cf1a57 100644 --- a/mfshell/commands/list.c +++ b/mfshell/commands/list.c @@ -18,6 +18,7 @@ */ #include +#include #include "../../mfapi/apicalls.h" #include "../mfshell.h" @@ -52,6 +53,11 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) printf("%s %s\n", folder_get_name(folder_result[i]), folder_get_key(folder_result[i])); } + for (i = 0; folder_result[i] != NULL; i++) { + folder_free(folder_result[i]); + } + free(folder_result); + // then files file_result = NULL; retval = @@ -62,5 +68,10 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) printf("%s %s\n", file_get_name(file_result[i]), file_get_key(file_result[i])); } + for (i = 0; file_result[i] != NULL; i++) { + file_free(file_result[i]); + } + free(file_result); + return retval; }