mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
trace list - different alloc
This commit is contained in:
parent
3716d4d823
commit
1621b0e7c8
1 changed files with 10 additions and 4 deletions
|
@ -632,7 +632,9 @@ int CmdTraceList(const char *Cmd) {
|
||||||
// reserve some space.
|
// reserve some space.
|
||||||
if (g_trace)
|
if (g_trace)
|
||||||
free(g_trace);
|
free(g_trace);
|
||||||
|
|
||||||
g_traceLen = 0;
|
g_traceLen = 0;
|
||||||
|
|
||||||
g_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
g_trace = calloc(PM3_CMD_DATA_SIZE, sizeof(uint8_t));
|
||||||
if (g_trace == NULL) {
|
if (g_trace == NULL) {
|
||||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||||
|
@ -645,18 +647,22 @@ int CmdTraceList(const char *Cmd) {
|
||||||
PacketResponseNG response;
|
PacketResponseNG response;
|
||||||
if (!GetFromDevice(BIG_BUF, g_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) {
|
if (!GetFromDevice(BIG_BUF, g_trace, PM3_CMD_DATA_SIZE, 0, NULL, 0, &response, 4000, true)) {
|
||||||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||||
|
free(g_trace);
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_traceLen = response.oldarg[2];
|
g_traceLen = response.oldarg[2];
|
||||||
|
|
||||||
|
// if tracelog buffer was larger and we need to download more.
|
||||||
if (g_traceLen > PM3_CMD_DATA_SIZE) {
|
if (g_traceLen > PM3_CMD_DATA_SIZE) {
|
||||||
uint8_t *p = realloc(g_trace, g_traceLen);
|
|
||||||
if (p == NULL) {
|
free(g_trace);
|
||||||
|
g_trace = calloc(g_traceLen, sizeof(uint8_t));
|
||||||
|
if (g_trace == NULL) {
|
||||||
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
PrintAndLogEx(FAILED, "Cannot allocate memory for trace");
|
||||||
free(g_trace);
|
|
||||||
return PM3_EMALLOC;
|
return PM3_EMALLOC;
|
||||||
}
|
}
|
||||||
g_trace = p;
|
|
||||||
if (!GetFromDevice(BIG_BUF, g_trace, g_traceLen, 0, NULL, 0, NULL, 2500, false)) {
|
if (!GetFromDevice(BIG_BUF, g_trace, g_traceLen, 0, NULL, 0, NULL, 2500, false)) {
|
||||||
PrintAndLogEx(WARNING, "command execution time out");
|
PrintAndLogEx(WARNING, "command execution time out");
|
||||||
free(g_trace);
|
free(g_trace);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue