From: Daniel Golle Date: Sun, 5 Sep 2021 13:22:33 +0000 (+0100) Subject: trace: don't leak file descriptor in error path X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8a60e7e066cb0b364cae13c524dce16743633b0a;p=project%2Fprocd.git trace: don't leak file descriptor in error path Coverity CID: 1491022 Resource leak Signed-off-by: Daniel Golle --- diff --git a/trace/trace.c b/trace/trace.c index 40cf3df..d895798 100644 --- a/trace/trace.c +++ b/trace/trace.c @@ -163,8 +163,10 @@ static void print_syscalls(int policy, const char *json) FILE *fp = fopen(json, "w"); if (fp) { tmp = blobmsg_format_json_indent(b.head, true, 0); - if (!tmp) + if (!tmp) { + fclose(fp); return; + } fprintf(fp, "%s\n", tmp); free(tmp);