cppcheck: a few mem alloc checks

This commit is contained in:
Philippe Teuwen committed 2025-03-24 10:44:01 +01:00
1 parent f3367e61db
commit 678b387c3f
8 files changed
+37

No files matched your search

+4
View File
@@ -82,6 +82,10 @@ static int CmdHFEPACollectPACENonces(const char *Cmd) {
size_t nonce_length = resp.oldarg[1];
size_t nonce_length_bytes = 2 * nonce_length + 1;
char *nonce = (char *) calloc(2 * nonce_length + 1, sizeof(uint8_t));
if (nonce == NULL) {
PrintAndLogEx(FAILED, "Memory allocation failed for nonce");
return PM3_EMALLOC;
}
for (int j = 0; j < nonce_length; j++) {
int nonce_offset = 2 * j;
snprintf(nonce + nonce_offset, (nonce_length_bytes * sizeof(uint8_t)) - nonce_offset, "%02X", resp.data.asBytes[j]);