1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virDomainDiskSourceFormatInternal: Avoid leaking @childBuf

If formatting of storage encryption or private data fails we must
jump to the error label instead of returning immediately
otherwise @attrBuf and @childBuf might be leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Michal Privoznik 2018-02-20 12:22:26 +01:00
parent a4ace767cd
commit 4e657f2ae2

View File

@ -22911,10 +22911,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf,
* as we found it. */
if (src->encryption && src->encryptionInherited &&
virStorageEncryptionFormat(&childBuf, src->encryption) < 0)
return -1;
goto error;
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
return -1;
goto error;
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
goto error;