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
|
* is NULL or whether it was the live xml of the domain moments
|
||||||
* before. */
|
* before. */
|
||||||
if (xmlin) {
|
if (xmlin) {
|
||||||
virDomainDefPtr def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
|
|
||||||
if (!(def = virDomainDefParseString(xmlin, driver->xmlopt,
|
if (!(def = virDomainDefParseString(xmlin, driver->xmlopt,
|
||||||
priv->qemuCaps,
|
priv->qemuCaps,
|
||||||
@ -3364,10 +3364,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver,
|
|||||||
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) {
|
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE))) {
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
if (!qemuDomainCheckABIStability(driver, vm, def)) {
|
if (!qemuDomainCheckABIStability(driver, vm, def))
|
||||||
virDomainDefFree(def);
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, true, true);
|
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, def, NULL, true, true);
|
||||||
} else {
|
} else {
|
||||||
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def,
|
xml = qemuDomainDefFormatLive(driver, priv->qemuCaps, vm->def,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user