Liu Song’s Projects


~/Projects/proxmark3

git clone https://code.lsong.org/proxmark3

Commit

Commit
82d80cc2507bb3a62e2dab2ace32fdb5b697910f
Author
iceman1001 <[email protected]>
Date
2023-07-14 11:33:47 +0200 +0200
Diffstat
 client/src/cmdhfmf.c | 9 ---------
 client/src/fileutils.c | 1 +

better memory clean up,   thanks @gentilkiwi


diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c
index b48fd3d0a70b6667986d185af28344e240563faa..3f704ad625e06689cecf63ec458b37f058eca76f 100644
--- a/client/src/cmdhfmf.c
+++ b/client/src/cmdhfmf.c
@@ -577,9 +577,6 @@
     size_t alen = 0, blen = 0;
     uint8_t *keyA, *keyB;
     if (loadFileBinaryKey(keyfn, "", (void **)&keyA, (void **)&keyB, &alen, &blen) != PM3_SUCCESS) {
-        if (keyA) {
-            free(keyA);
-        }
         free(fptr);
         return PM3_ESOFT;
     }
@@ -1339,9 +1336,6 @@     //
     size_t alen = 0, blen = 0;
     uint8_t *keyA, *keyB;
     if (loadFileBinaryKey(keyfilename, "", (void **)&keyA, (void **)&keyB, &alen, &blen) != PM3_SUCCESS) {
-        if (keyA) {
-            free(keyA);
-        }
         return PM3_ESOFT;
     }
 
@@ -6289,9 +6283,6 @@         //
         size_t alen = 0, blen = 0;
         uint8_t *tmpA, *tmpB;
 static int mf_analyse_st_block(uint8_t blockno, uint8_t *block, bool force) {
-            if (tmpA) {
-                free(tmpA);
-#include "cmdhfmfhard.h"
             goto skipfile;
         }
 




diff --git a/client/src/fileutils.c b/client/src/fileutils.c
index f266da9b2c30a3b2eacbf25b9b4f4928c1f42264..7ca59ef85d729c2f6d5d13e2f0862676857e0d44 100644
--- a/client/src/fileutils.c
+++ b/client/src/fileutils.c
@@ -1609,6 +1609,7 @@     *keyb = calloc(fsize, sizeof(uint8_t));
     if (*keyb == NULL) {
         PrintAndLogEx(FAILED, "error, cannot allocate memory");
         fclose(f);
+        free(*keya);
         return PM3_EMALLOC;
     }