From a9b4e523d7a6fee6c0d3e9eda0cd5a1d838e1d38 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 30 Sep 2020 15:03:59 +0200 Subject: [PATCH] qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c index 6f7d94bd2c..f901041ee1 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1211,7 +1211,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, g_autofree char *uuid = NULL; g_autofree char *hostuuid = NULL; char localdomuuid[VIR_UUID_STRING_BUFLEN]; - xmlNodePtr *nodes = NULL; /* We don't store the uuid, name, hostname, or hostuuid * values. We just compare them to local data to do some @@ -1296,6 +1295,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && virXPathBoolean("count(./domain) > 0", ctxt)) { + g_autofree xmlNodePtr *nodes = NULL; + if ((virXPathNodeSet("./domain", ctxt, &nodes)) != 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Too many domain elements in migration cookie")); @@ -1311,7 +1312,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, * an error for us */ goto error; } - VIR_FREE(nodes); } if ((flags & QEMU_MIGRATION_COOKIE_NETWORK) && @@ -1344,7 +1344,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, return 0; error: - VIR_FREE(nodes); return -1; } -- 2.47.2