FIX: 'mem load' - bad memory allocation

CHG: calloc fixes
This commit is contained in:
iceman1001 2018-12-17 14:01:18 +01:00
parent cecf709fe7
commit a963a7834c
2 changed files with 6 additions and 4 deletions

View file

@ -182,9 +182,9 @@ int CmdFlashMemLoad(const char *Cmd){
//Validations
if (errors || cmdp == 0 ) return usage_flashmem_load();
uint8_t *data = NULL;
uint8_t *data = calloc(FLASH_MEM_MAX_SIZE, sizeof(uint8_t));
size_t datalen = 0;
int res = loadFile(filename, "bin", &data, &datalen);
int res = loadFile(filename, "bin", data, &datalen);
//int res = loadFileEML( filename, "eml", data, &datalen);
if ( res ) {
free(data);
@ -196,6 +196,8 @@ int CmdFlashMemLoad(const char *Cmd){
free(data);
return 1;
}
data = realloc(data, datalen);
//Send to device
uint32_t bytes_sent = 0;

View file

@ -2414,7 +2414,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
param_getstr(Cmd, nameParamNo, filename, sizeof(filename));
uint8_t *data = calloc(1, 4096);
uint8_t *data = calloc(4096, sizeof(uint8_t));
size_t datalen = 0;
//int res = loadFile(filename, "bin", data, &datalen);
int res = loadFileEML( filename, "eml", data, &datalen);
@ -2693,7 +2693,7 @@ int CmdHF14AMfCLoad(const char *Cmd) {
}
size_t maxdatalen = 4096;
uint8_t *data = calloc(1, maxdatalen);
uint8_t *data = calloc(maxdatalen, sizeof(uint8_t));
size_t datalen = 0;
int res = 0;
if (fillFromBin) {