summaryrefslogtreecommitdiff
path: root/trace
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-08-30 20:20:49 +0100
committerDaniel Golle <daniel@makrotopia.org>2021-08-30 20:30:43 +0100
commite5b38fd1298cec50f68b01568fcecf5e626cd286 (patch)
tree74d7ae694ce9fb3a14110c447f4e1e1ef525b149 /trace
parentdf251c2cbad9a14dc632a7f44ff6baee3a72b043 (diff)
downloadprocd-e5b38fd1298cec50f68b01568fcecf5e626cd286.tar.gz
trace: free memory allocated by blobmsg_format_json_indent()
Only one out of two occurances have been addressed previously. Close the other one now. Coverity CID: 1446205 Fixes: 51f1cd23 ("trace: free string returned by blobmsg_format_json_indent()") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'trace')
-rw-r--r--trace/trace.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/trace/trace.c b/trace/trace.c
index 8d90b5e..87a98a6 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -162,7 +162,12 @@ static void print_syscalls(int policy, const char *json)
if (json) {
FILE *fp = fopen(json, "w");
if (fp) {
- fprintf(fp, "%s\n", blobmsg_format_json_indent(b.head, true, 0));
+ tmp = blobmsg_format_json_indent(b.head, true, 0);
+ if (!tmp)
+ return;
+
+ free(tmp);
+ fprintf(fp, "%s\n", tmp);
fclose(fp);
ULOG_INFO("saving syscall trace to %s\n", json);
} else {
@@ -176,7 +181,6 @@ static void print_syscalls(int policy, const char *json)
printf("%s\n", tmp);
free(tmp);
}
-
}
static void report_seccomp_vialation(pid_t pid, unsigned syscall)