diff --git a/client/cmdhffelica.c b/client/cmdhffelica.c index 33d506a58..08319840a 100644 --- a/client/cmdhffelica.c +++ b/client/cmdhffelica.c @@ -425,34 +425,33 @@ int CmdHFFelicaDumpLite(const char *Cmd) { } uint64_t tracelen = resp.arg[1]; + if (tracelen == 0) + return 1; + uint8_t *trace = calloc(tracelen, sizeof(uint8_t)); if (trace == NULL) { PrintAndLogEx(WARNING, "Cannot allocate memory for trace"); return 1; } - // only download data if there is any. - if (tracelen > 0) { - - if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) { - PrintAndLogEx(WARNING, "command execution time out"); - free(trace); - return 0; - } - - PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen); - - print_hex_break(trace, tracelen, 32); - - printSep(); - uint16_t tracepos = 0; - while (tracepos < tracelen) - tracepos = PrintFliteBlock(tracepos, trace, tracelen); - - printSep(); + if (!GetFromDevice(BIG_BUF, trace, tracelen, 0, NULL, 2500, false)) { + PrintAndLogEx(WARNING, "command execution time out"); + free(trace); + return 0; } - free(trace); + PrintAndLogEx(SUCCESS, "Recorded Activity (trace len = %d bytes)", tracelen); + + print_hex_break(trace, tracelen, 32); + printSep(); + + uint16_t tracepos = 0; + while (tracepos < tracelen) + tracepos = PrintFliteBlock(tracepos, trace, tracelen); + + printSep(); + + free(trace); return 0; }