Restructure the control-flow a bit using an temporary variable to avoid the need to use VIR_FREE. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_migration_cookie.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c index 93d91b8a1c..84274301dc 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1218,15 +1218,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, if ((flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) && virXPathBoolean("count(./lockstate) > 0", ctxt)) { + g_autofree char *lockState = NULL; + mig->lockDriver = virXPathString("string(./lockstate[1]/@driver)", ctxt); if (!mig->lockDriver) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing lock driver name in migration cookie")); return -1; } - mig->lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt); - if (mig->lockState && STREQ(mig->lockState, "")) - VIR_FREE(mig->lockState); + + lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt); + if (STRNEQ_NULLABLE(lockState, "")) + mig->lockState = g_steal_pointer(&lockState); } if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && -- 2.26.2