Use calloc() instead of malloc()

Suggested by @iceman1001
Mainly for 8b6a274e28
Replaced the malloc() in getSamplesFromBufEx()
Added memory allocation result check for getSamplesFromBufEx(),
lf_read_internal(), and lf_sniff()
This commit is contained in:
wh201906 committed 2023-11-17 12:38:20 +08:00
1 parent 3ee13c9ba6
commit e82fb8b67f
4 files changed
+31 -19

No files matched your search

+1 -1
View File
@@ -117,7 +117,7 @@ int demodHID(bool verbose) {
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
uint32_t hi2 = 0, hi = 0, lo = 0;
uint8_t *bits = malloc(g_GraphTraceLen);
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
if (bits == NULL) {
PrintAndLogEx(FAILED, "failed to allocate memory");
return PM3_EMALLOC;