mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-05 13:55:47 +00:00
Fix memory leak while scanning snapshots
If a snapshot with the name already exists, virDomainSnapshotAssignDef() just returns NULL, in which case the snapshot definition is leaked. Currently this leak is not a big problem, since qemuDomainSnapshotLoad() is only called once during initial startup of libvirtd. Signed-off-by: Philipp Hahn <hahn@univention.de>
This commit is contained in:
parent
e6cdb431bd
commit
839a5295ef
@ -293,6 +293,7 @@ static void qemuDomainSnapshotLoad(void *payload,
|
|||||||
int ret;
|
int ret;
|
||||||
char *fullpath;
|
char *fullpath;
|
||||||
virDomainSnapshotDefPtr def = NULL;
|
virDomainSnapshotDefPtr def = NULL;
|
||||||
|
virDomainSnapshotObjPtr snap = NULL;
|
||||||
char ebuf[1024];
|
char ebuf[1024];
|
||||||
|
|
||||||
virDomainObjLock(vm);
|
virDomainObjLock(vm);
|
||||||
@ -344,7 +345,10 @@ static void qemuDomainSnapshotLoad(void *payload,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainSnapshotAssignDef(&vm->snapshots, def);
|
snap = virDomainSnapshotAssignDef(&vm->snapshots, def);
|
||||||
|
if (snap == NULL) {
|
||||||
|
virDomainSnapshotDefFree(def);
|
||||||
|
}
|
||||||
|
|
||||||
VIR_FREE(fullpath);
|
VIR_FREE(fullpath);
|
||||||
VIR_FREE(xmlStr);
|
VIR_FREE(xmlStr);
|
||||||
|
Loading…
Reference in New Issue
Block a user