Browse Source

uxc: free string returned by blobmsg_format_json_indent()

Coverity ID: 1490068 Resource leak

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 2 years ago
parent
commit
f6daca3bf4
1 changed files with 10 additions and 1 deletions
  1. 10 1
      uxc.c

+ 10 - 1
uxc.c

@@ -361,6 +361,7 @@ static int uxc_state(char *name)
 	char *bundle = NULL;
 	char *jail_name = NULL;
 	char *state = NULL;
+	char *tmp;
 	static struct blob_buf buf;
 
 	if (s)
@@ -401,7 +402,15 @@ static int uxc_state(char *name)
 	blobmsg_add_string(&buf, "status", s?"stopped":"uninitialized");
 	blobmsg_add_string(&buf, "bundle", bundle);
 
-	printf("%s\n", blobmsg_format_json_indent(buf.head, true, 0));
+	tmp = blobmsg_format_json_indent(buf.head, true, 0);
+	if (!tmp) {
+		blob_buf_free(&buf);
+		return ENOMEM;
+	}
+
+	printf("%s\n", tmp);
+	free(tmp);
+
 	blob_buf_free(&buf);
 
 	return 0;