From 1de6ddc8a59e170ab19dad22b41267c1a57153e0 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Tue, 10 Oct 2023 22:41:40 +0200 Subject: [PATCH] check id pointer --- src/trace/trace.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/trace/trace.c b/src/trace/trace.c index e38faffdb..18114c460 100644 --- a/src/trace/trace.c +++ b/src/trace/trace.c @@ -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; @@ -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,"