tools/libxl: avoid freeing stack rubble in libxl__json_object_to_json()

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: 75fa670e58 ("libxl: Convert libxl__json_object_to_json() to json_object")
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:
Roger Pau Monne committed 2025-10-16 17:20:18 +02:00
1 parent 98cdab1679
commit 3539308d82
1 file changed
+1 -1
+1 -1
View File
@@ -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;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.