fix memory leak in list command

This commit is contained in:
josch
2014-09-25 19:32:28 +02:00
parent 0fab559a86
commit fd13d973ba

View File

@@ -18,6 +18,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#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;
}