From 9ce820768c7778db6620511bdf51f32fb7f09f66 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 7 Sep 2019 12:07:09 +0200 Subject: [PATCH] missing free --- client/fileutils.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/client/fileutils.c b/client/fileutils.c index 3abdcc4f0..9a5907882 100644 --- a/client/fileutils.c +++ b/client/fileutils.c @@ -415,8 +415,10 @@ int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, s FILE *f = fopen(path, "rb"); if (!f) { PrintAndLogEx(WARNING, "file not found or locked. '" _YELLOW_("%s")"'", path); + free(path); return PM3_EFILE; } + free(path); // get filesize in order to malloc memory fseek(f, 0, SEEK_END); @@ -425,7 +427,6 @@ int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, s if (fsize <= 0) { PrintAndLogEx(FAILED, "error, when getting filesize"); - free(path); fclose(f); return PM3_EFILE; } @@ -433,7 +434,6 @@ int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, s *pdata = calloc(fsize, sizeof(uint8_t)); if (!pdata) { PrintAndLogEx(FAILED, "error, cannot allocate memory"); - free(path); fclose(f); return PM3_EMALLOC; } @@ -444,14 +444,12 @@ int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, s if (bytes_read != fsize) { PrintAndLogEx(FAILED, "error, bytes read mismatch file size"); - free(path); return PM3_EFILE; } *datalen = bytes_read; PrintAndLogEx(SUCCESS, "loaded %d bytes from binary file " _YELLOW_("%s"), bytes_read, preferredName); - free(path); return retval; }