From 49ef0f95c6425bb248364649dd042eaea1d3e142 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 29 Apr 2022 14:31:43 +0200 Subject: [PATCH] qemuMigrationSrcBegin: Automatically free 'xml' variable on error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_migration.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 25af291dc6..6b3815ac58 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2487,7 +2487,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, { virQEMUDriver *driver = conn->privateData; g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); - char *xml = NULL; + g_autofree char *xml = NULL; virDomainAsyncJob asyncJob; if (cfg->migrateTLSForce && @@ -2532,10 +2532,8 @@ qemuMigrationSrcBegin(virConnectPtr conn, * place. */ if (virCloseCallbacksSet(driver->closeCallbacks, vm, conn, - qemuMigrationSrcCleanup) < 0) { - VIR_FREE(xml); + qemuMigrationSrcCleanup) < 0) goto endjob; - } qemuMigrationJobContinue(vm); } else { goto endjob; @@ -2543,7 +2541,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, cleanup: virDomainObjEndAPI(&vm); - return xml; + return g_steal_pointer(&xml); endjob: if (flags & VIR_MIGRATE_CHANGE_PROTECTION)