psApdu->prgbCData = (byte_t*)malloc(APDU_BUFFER_LENGTH);
memset((void*)psApdu->prgbCData, 0, APDU_BUFFER_LENGTH);
byte_t prgData[] = { 0x01, 0x38, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02 };
memcpy((byte*)psApdu->prgbCData, prgData, sizeof(prgData));
free(psApdu->prgbCData);
‘free’ statement failing here. What is the reason?
Firstly, you shouldn’t cast to and from
void *. Alsosizeofis an operator.You need to check that
sizeof prgData <= APDU_BUFFER_LENGTH. You could try this with a static assertion: