Skip to content

Commit

Permalink
Merge pull request #2196 from hazardousvoltage/unisniff
Browse files Browse the repository at this point in the history
cmdtrace.c: fix segfault in 'trace list' after failed load
  • Loading branch information
iceman1001 authored Dec 6, 2023
2 parents 75d0601 + 6b8a269 commit 75ba439
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/cmdtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,9 @@ static int CmdTraceLoad(const char *Cmd) {
CLIParserFree(ctx);

if (gs_trace) {
free(gs_trace);
free(gs_trace); // maybe better to not clobber this until we have successful load?
gs_trace = NULL;
gs_traceLen = 0;
}

size_t len = 0;
Expand Down Expand Up @@ -1292,7 +1293,7 @@ int CmdTraceList(const char *Cmd) {

if (use_buffer == false) {
download_trace();
} else if (gs_traceLen == 0) {
} else if (gs_traceLen == 0 || gs_trace ==NULL) {
PrintAndLogEx(FAILED, "You requested a trace list in offline mode but there is no trace.");
PrintAndLogEx(FAILED, "Consider using " _YELLOW_("`trace load`") " or removing parameter " _YELLOW_("`-1`"));
return PM3_EINVARG;
Expand Down

0 comments on commit 75ba439

Please sign in to comment.