Skip to content

Commit

Permalink
check id pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Oct 11, 2023
1 parent 7326179 commit 1de6ddc
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ int re_trace_flush(void)
int i, flush_count;
struct trace_event *event_tmp;
struct trace_event *e;
char json_arg[256];
char name[128];
char id_str[128];
char json_arg[256] = {0};
char name[128] = {0};
char id_str[128] = {0};

#ifndef RE_TRACE_ENABLED
return 0;
Expand Down Expand Up @@ -291,8 +291,12 @@ int re_trace_flush(void)
}

re_snprintf(name, sizeof(name), "\"name\":\"%s\"", e->name);
re_snprintf(id_str, sizeof(id_str), "\"id\":\"%r\"", e->id);
mem_deref(e->id);

if (e->id) {
re_snprintf(id_str, sizeof(id_str), "\"id\":\"%r\"",
e->id);
mem_deref(e->id);
}

(void)re_fprintf(trace.f,
"%s{\"cat\":\"%s\",\"pid\":%i,\"tid\":%lu,\"ts\":%Lu,"
Expand Down

0 comments on commit 1de6ddc

Please sign in to comment.