mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-13 02:34:48 +08:00
chg: use calloc
This commit is contained in:
parent
8991fa172d
commit
18db34ffb0
3 changed files with 4 additions and 4 deletions
|
@ -1786,7 +1786,7 @@ int Cmdbin2hex(const char *Cmd) {
|
|||
//Number of digits supplied as argument
|
||||
size_t length = en - bg + 1;
|
||||
size_t bytelen = (length+7) / 8;
|
||||
uint8_t* arr = (uint8_t *) malloc(bytelen);
|
||||
uint8_t* arr = (uint8_t *) calloc(bytelen, sizeof(uint8_t));
|
||||
memset(arr, 0, bytelen);
|
||||
BitstreamOut bout = { arr, 0, 0 };
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int CmdHFEPACollectPACENonces(const char *Cmd)
|
|||
PrintAndLogEx(FAILED, "Error in step %d, Return code: %d",resp.arg[0],(int)resp.arg[1]);
|
||||
} else {
|
||||
size_t nonce_length = resp.arg[1];
|
||||
char *nonce = (char *) malloc(2 * nonce_length + 1);
|
||||
char *nonce = (char *) calloc(2 * nonce_length + 1, sizeof(uint8_t));
|
||||
for(int j = 0; j < nonce_length; j++) {
|
||||
sprintf(nonce + (2 * j), "%02X", resp.d.asBytes[j]);
|
||||
}
|
||||
|
|
|
@ -404,7 +404,7 @@ int CmdHFiClassSim(const char *Cmd) {
|
|||
break;
|
||||
|
||||
size_t datalen = NUM_CSNS * 24;
|
||||
void* dump = malloc(datalen);
|
||||
void* dump = calloc(datalen, sizeof(uint8_t));
|
||||
if ( !dump ) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return 2;
|
||||
|
@ -456,7 +456,7 @@ int CmdHFiClassSim(const char *Cmd) {
|
|||
break;
|
||||
|
||||
size_t datalen = NUM_CSNS * 24;
|
||||
void* dump = malloc(datalen);
|
||||
void* dump = calloc(datalen, sizeof(uint8_t));
|
||||
if ( !dump ) {
|
||||
PrintAndLogEx(WARNING, "Failed to allocate memory");
|
||||
return 2;
|
||||
|
|
Loading…
Reference in a new issue