Message ID | 20220126095154.570700-8-tz.stoyanov@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3fcc509b7682a4bb14ba5b094c1dace1854d49cf |
Headers | show |
Series | *trace-cmd convert | expand |
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c index b54c68fe..c1ba8a52 100644 --- a/lib/trace-cmd/trace-output.c +++ b/lib/trace-cmd/trace-output.c @@ -227,8 +227,10 @@ void tracecmd_set_quiet(struct tracecmd_output *handle, bool set_quiet) void tracecmd_set_out_clock(struct tracecmd_output *handle, const char *clock) { - if (handle && clock) + if (handle && clock) { + free(handle->trace_clock); handle->trace_clock = strdup(clock); + } } /**
The API for setting a trace clock to a input handle did not check if the clock is already set: tracecmd_set_out_clock() This could cause a memory leak, if the clock is already set - the old clock string is overwritten. The old clock should be freed before setting the new one. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)