From: Peter Krempa Date: Wed, 30 Sep 2020 13:03:59 +0000 (+0200) Subject: qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing X-Git-Tag: v6.9.0-rc1~347 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9b4e523d7a6fee6c0d3e9eda0cd5a1d838e1d38;p=thirdparty%2Flibvirt.git qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- 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; }