summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2021-08-23 17:07:19 +0000
committerDaniel Golle2021-08-24 17:31:56 +0000
commit51f1cd2366ebfc1f4ebbbfc819d36086ed3b5eb9 (patch)
treea62130b2ac9bdc4ad46908c6d6fc9a365b9d69d7
parentf6daca3bf4aee7874f2a2b05b5b82d5fdf35e6a4 (diff)
downloadprocd-51f1cd2366ebfc1f4ebbbfc819d36086ed3b5eb9.tar.gz
trace: free string returned by blobmsg_format_json_indent()
Coverity CID: 1446205 Resource leak Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--trace/trace.c9
1 files 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);
}
}