Message ID | 20220119082845.245993-8-tz.stoyanov@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | trace-cmd convert | expand |
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c index 612cb63d..78232bc9 100644 --- a/lib/trace-cmd/trace-output.c +++ b/lib/trace-cmd/trace-output.c @@ -216,8 +216,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(-)