mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
fix a sanity memory leak with reserving memory used only for json file loading..
This commit is contained in:
parent
550fa5aa8f
commit
8243ac9749
6 changed files with 71 additions and 71 deletions
|
@ -1978,12 +1978,7 @@ static int CmdHF15Restore(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "Using block size... %d", blocksize);
|
||||
|
||||
// 4bytes * 256 blocks. Should be enough..
|
||||
uint8_t *data = calloc(4 * 256, sizeof(uint8_t));
|
||||
if (data == NULL) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
|
||||
uint8_t *data = NULL;
|
||||
size_t datalen = 0;
|
||||
int res = PM3_SUCCESS;
|
||||
DumpFileType_t dftype = getfiletype(filename);
|
||||
|
@ -1997,7 +1992,12 @@ static int CmdHF15Restore(const char *Cmd) {
|
|||
break;
|
||||
}
|
||||
case JSON: {
|
||||
res = loadFileJSON(filename, data, 256 * 4, &datalen, NULL);
|
||||
data = calloc(4 * 256, sizeof(uint8_t));
|
||||
if (data == NULL) {
|
||||
PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
res = loadFileJSON(filename, (void *)data, 256 * 4, &datalen, NULL);
|
||||
break;
|
||||
}
|
||||
case DICTIONARY: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue