diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 65f193647..028db71e0 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -676,16 +676,16 @@ int saveFileJSONroot(const char *preferredName, void *root, size_t flags, bool v int res = json_dump_file(root, filename, flags); - free(filename); - if ( res == 0 ) { if (verbose) { PrintAndLogEx(SUCCESS, "saved to json file " _YELLOW_("%s"), filename); } + free(filename); return PM3_SUCCESS; } else { PrintAndLogEx(FAILED, "error: can't save the file: " _YELLOW_("%s"), filename); } + free(filename); return PM3_EFILE; }