mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemu: fix memory leak in qemuDomainSaveInternal()
Use g_autoptr to free the temporary virDomainDef object created by
qemuDomainSaveInternal() when xmlin is non-NULL. Leak was added in
commit 0ea479f8f6
, first appearing in libvirt 0.9.4 in August 2011.
Signed-off-by: Zheng Chuan <zhengchuan@huawei.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
8a4f807536
commit
ffa7fab440
@ -3356,7 +3356,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
||||
* is NULL or whether it was the live xml of the domain moments
|
||||
* before. */
|
||||
if (xmlin) {
|
||||
virDomainDefPtr def = NULL;
|
||||
g_autoptr(virDomainDef) def = NULL;
|
||||
|
||||
if (!(def = virDomainDefParseString(xmlin, driver->xmlopt,
|
||||
priv->qemuCaps,
|
||||
@ -3364,10 +3364,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) {
|
||||
goto endjob;
|
||||
}
|
||||
if (!qemuDomainCheckABIStability(driver, vm, def)) {
|
||||
virDomainDefFree(def);
|
||||
if (!qemuDomainCheckABIStability(driver, vm, def))
|
||||
goto endjob;
|
||||
}
|
||||
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, true, true);
|
||||
} else {
|
||||
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def,
|
||||
|
Loading…
Reference in New Issue
Block a user