From 3539308d8206e64526f66726f5514330f2ff10d5 Mon Sep 17 00:00:00 2001 From: Roger Pau Monne Date: Wed, 15 Oct 2025 14:02:17 +0200 Subject: [PATCH] tools/libxl: avoid freeing stack rubble in libxl__json_object_to_json() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-by: Andrew Cooper Reviewed-by: Jason Andryuk Release-Acked-by: Oleksii Kurochko --- 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 e895cca4cf..68f36901c2 100644 --- a/tools/libs/light/libxl_json.c +++ b/tools/libs/light/libxl_json.c @@ -1531,7 +1531,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;