On 04/05/2012 01:34 PM, Laine Stump wrote: > On 04/05/2012 03:16 PM, Eric Blake wrote: >> Leak introduced in commit 0436d32. If we allocate an actions array, >> but fail early enough to never consume it with the qemu monitor >> transaction call, we leaked memory. >> >> * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive): >> Free actions array on failure. >> --- >> src/qemu/qemu_driver.c | 2 ++ >> 1 files changed, 2 insertions(+), 0 deletions(-) >> >> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c >> index b29029e..a214593 100644 >> --- a/src/qemu/qemu_driver.c >> +++ b/src/qemu/qemu_driver.c >> @@ -10132,6 +10132,8 @@ qemuDomainSnapshotCreateDiskActive(virConnectPtr conn, >> if (actions) { >> if (ret == 0) >> ret = qemuMonitorTransaction(priv->mon, actions); >> + else >> + virJSONValueFree(actions); >> if (ret < 0) { >> /* Transaction failed; undo the changes to vm. */ >> bool need_unlink = !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT); > > ACK. Shoot - I just realized that I missed a spot. The semantics of consuming an array are a bit confusing, since it means everyone along the chain must participate in those semantics. Better is to make the person that allocates also do the free, but that requires a bit more hacking to avoid double-freeing things when recursively deleting the 'transaction' JSON command that wraps the actions array. v2 coming up. -- Eric Blake eblake@xxxxxxxxxx +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list