trace: free string returned by blobmsg_format_json_indent()
authorDaniel Golle <daniel@makrotopia.org>
Mon, 23 Aug 2021 17:07:19 +0000 (18:07 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 24 Aug 2021 17:31:56 +0000 (18:31 +0100)
Coverity CID: 1446205 Resource leak

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
trace/trace.c

index dab92e06c4275e35e2f0dee2d0f16b79ad0b29a9..eec21f8b744e22cc6d3891df202faa6daaf87906 100644 (file)
@@ -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);
        }
 
 }