From 51f1cd2366ebfc1f4ebbbfc819d36086ed3b5eb9 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 23 Aug 2021 18:07:19 +0100 Subject: [PATCH] trace: free string returned by blobmsg_format_json_indent() Coverity CID: 1446205 Resource leak Signed-off-by: Daniel Golle --- trace/trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trace/trace.c b/trace/trace.c index dab92e0..eec21f8 100644 --- a/trace/trace.c +++ b/trace/trace.c @@ -117,6 +117,7 @@ static void print_syscalls(int policy, const char *json) { void *c, *d, *e; int i; + char *tmp; if (mode == UTRACE) { set_syscall("rt_sigaction", 1); @@ -168,8 +169,12 @@ static void print_syscalls(int policy, const char *json) ULOG_ERR("failed to open %s\n", json); } } else { - printf("%s\n", - blobmsg_format_json_indent(b.head, true, 0)); + tmp = blobmsg_format_json_indent(b.head, true, 0); + if (!tmp) + return; + + printf("%s\n", tmp); + free(tmp); } } -- 2.30.2