It's possible for libxl__json_object_to_json_object() to not set the passed
jso_out parameter, hence initialize it in libxl__json_object_to_json() to
avoid freeing an uninitialized pointer in case of failure.

Reported by XenServer internal Coverity instance.

Fixes: 75fa670e582c ("libxl: Convert libxl__json_object_to_json() to 
json_object")
Signed-off-by: Roger Pau Monné <[email protected]>
---
 tools/libs/light/libxl_json.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libs/light/libxl_json.c b/tools/libs/light/libxl_json.c
index a9e06b06932d..b01d86363550 100644
--- a/tools/libs/light/libxl_json.c
+++ b/tools/libs/light/libxl_json.c
@@ -1533,7 +1533,7 @@ char *libxl__json_object_to_json(libxl__gc *gc,
 {
 #ifdef HAVE_LIBJSONC
     const char *buf;
-    json_object *root;
+    json_object *root = NULL;
     char *ret = NULL;
     int rc;
 
-- 
2.51.0


Reply via email to