[18/38] trace-cmd: Have msg_free() zero out msg contents
diff mbox series

Message ID 20180103175337.414061220@goodmis.org
State New, archived
Headers show
  • trace-cmd: Simplify the msg handling
Related show

Commit Message

Steven Rostedt Jan. 3, 2018, 5:52 p.m. UTC
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

When msg_free() is called, the msg contents should never be used after that.
To ensure that it does not contain residual data, have msg_free() zero out
the msg before returning.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
 trace-msg.c | 2 ++
 1 file changed, 2 insertions(+)

diff mbox series

diff --git a/trace-msg.c b/trace-msg.c
index ff89c4478f6f..e1abbbb99bb4 100644
--- a/trace-msg.c
+++ b/trace-msg.c
@@ -233,6 +233,8 @@  static void msg_free(struct tracecmd_msg *msg)
 	/* If a min size is defined, then the buf needs to be freed */
 	if (cmd < MSG_FINMETA && (msg_min_sizes[cmd] > 0))
+	memset(msg, 0, sizeof(*msg));
 static int tracecmd_msg_send(int fd, struct tracecmd_msg *msg)