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:
Philipp Hahn 2011-08-09 15:47:57 +02:00 committed by Eric Blake
parent e6cdb431bd
commit 839a5295ef

View File

@ -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);