diff mbox series

[03/87] tarce-cmd library: Fix version string memory leak

Message ID 20210728133250.234140-4-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Trace file version 7 | expand

Commit Message

Tzvetomir Stoyanov (VMware) July 28, 2021, 1:31 p.m. UTC
The version string is allocated when a VERSION option is processed, but
is never freed. Free it on input hanlder close.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-input.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 6e7024a6..d5ffafd7 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -3517,6 +3517,7 @@  void tracecmd_close(struct tracecmd_input *handle)
 	free(handle->cpu_data);
 	free(handle->uname);
 	free(handle->trace_clock);
+	free(handle->version);
 	close(handle->fd);
 
 	tracecmd_free_hooks(handle->hooks);
@@ -3958,6 +3959,7 @@  tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
 	new_handle->cpu_data = NULL;
 	new_handle->nr_buffers = 0;
 	new_handle->buffers = NULL;
+	new_handle->version = NULL;
 	new_handle->ref = 1;
 	if (handle->trace_clock) {
 		new_handle->trace_clock = strdup(handle->trace_clock);
@@ -3970,6 +3972,7 @@  tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
 	new_handle->parent = handle;
 	new_handle->cpustats = NULL;
 	new_handle->hooks = NULL;
+	new_handle->version = NULL;
 	if (handle->uname)
 		/* Ignore if fails to malloc, no biggy */
 		new_handle->uname = strdup(handle->uname);