From: Michal Privoznik Date: Tue, 20 Feb 2018 11:22:26 +0000 (+0100) Subject: virDomainDiskSourceFormatInternal: Avoid leaking @childBuf X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4e657f2ae21c763c9cb001195e131a9d9c6db47c;p=libvirt.git 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 Reviewed-by: Daniel P. Berrangé --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 970efbb13c..3126cbb5b0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -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;