diff --git a/src/trace.c b/src/trace.c index eafc9945..6a2282d4 100644 --- a/src/trace.c +++ b/src/trace.c @@ -152,7 +152,12 @@ void tf_trace_end(tf_trace_t* trace) { stack = stack->next; } - const char* name = stack && stack->count > 0 ? stack->names[stack->count - 1] : NULL; + const char* name = NULL; + if (stack && stack->count > 0) + { + name = stack->names[stack->count - 1]; + stack->count--; + } char line[1024]; int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": 0, \"ts\": %" PRId64 ", \"name\": \"", getpid(), _trace_ts());