From 96d8bf2c7b6773636efb8b175993e5d17ff7d0bf Mon Sep 17 00:00:00 2001 From: Nick Hainke Date: Mon, 30 Aug 2021 22:37:10 +0200 Subject: [PATCH] trace: fix potential use-after-free occurence 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 --- trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) return; - free(tmp); fprintf(fp, "%s\n", tmp); + free(tmp); fclose(fp); ULOG_INFO("saving syscall trace to %s\n", json); } else { -- 2.30.2