提交 839a5295 编写于 作者: P Philipp Hahn 提交者: Eric Blake

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: NPhilipp Hahn <hahn@univention.de>
上级 e6cdb431
......@@ -293,6 +293,7 @@ static void qemuDomainSnapshotLoad(void *payload,
int ret;
char *fullpath;
virDomainSnapshotDefPtr def = NULL;
virDomainSnapshotObjPtr snap = NULL;
char ebuf[1024];
virDomainObjLock(vm);
......@@ -344,7 +345,10 @@ static void qemuDomainSnapshotLoad(void *payload,
continue;
}
virDomainSnapshotAssignDef(&vm->snapshots, def);
snap = virDomainSnapshotAssignDef(&vm->snapshots, def);
if (snap == NULL) {
virDomainSnapshotDefFree(def);
}
VIR_FREE(fullpath);
VIR_FREE(xmlStr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册