mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/xl: check return of json_object_object_add()
Check the return codes of json_object_object_add() calls in
printf_info_one_json().
Reported by XenServer internal Coverity instance.
Fixes: f6c6f2679d ("libxl: Convert libxl__object_to_json() to json-c")
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
This commit is contained in:
1 parent
3539308d82
commit
a4d92cf189
1 file changed
+9
-4
+9
-4
@@ -69,7 +69,7 @@ static int printf_info_one_json(json_object **jso_r, int domid,
|
||||
json_object *jso_config = NULL;
|
||||
enum json_tokener_error error = json_tokener_error_parse_unexpected;
|
||||
char *s = NULL;
|
||||
int r = EXIT_FAILURE;
|
||||
int r = EXIT_FAILURE, rc;
|
||||
|
||||
s = libxl_domain_config_to_json(ctx, d_config);
|
||||
jso_config = json_tokener_parse_verbose(s, &error);
|
||||
@@ -81,12 +81,17 @@ static int printf_info_one_json(json_object **jso_r, int domid,
|
||||
|
||||
jso = json_object_new_object();
|
||||
if (domid != -1)
|
||||
json_object_object_add(jso, "domid", json_object_new_int(domid));
|
||||
rc = json_object_object_add(jso, "domid", json_object_new_int(domid));
|
||||
else
|
||||
json_object_object_add(jso, "domid", json_object_new_null());
|
||||
rc = json_object_object_add(jso, "domid", json_object_new_null());
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
|
||||
json_object_object_add(jso, "config", jso_config);
|
||||
rc = json_object_object_add(jso, "config", jso_config);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
jso_config = NULL;
|
||||
|
||||
*jso_r = jso;
|
||||
|
||||