diff mbox series

trace: fix potential use-after-free occurence

Message ID 20210830203710.18792-1-vincent@systemli.org
State New
Headers show
Series trace: fix potential use-after-free occurence | expand

Commit Message

Nick Aug. 30, 2021, 8:37 p.m. UTC
From: Nick Hainke <vincent@systemli.org>

char* tmp is used in the fprintf function altough it is already freed.

Fixes: e5b38fd1 ("trace: free memory allocated by blobmsg_format_json_indent()")

Signed-off-by: Nick Hainke <vincent@systemli.org>
 trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


diff --git a/trace/trace.c b/trace/trace.c
index 87a98a6..40cf3df 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -166,8 +166,8 @@  static void print_syscalls(int policy, const char *json)
 			if (!tmp)
-			free(tmp);
 			fprintf(fp, "%s\n", tmp);
+			free(tmp);
 			ULOG_INFO("saving syscall trace to %s\n", json);
 		} else {