]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainDiskSourceFormatInternal: Avoid leaking @childBuf
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Feb 2018 11:22:26 +0000 (12:22 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Feb 2018 12:06:22 +0000 (13:06 +0100)
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>
src/conf/domain_conf.c

index 970efbb13cb73e384441591044fca3d1ffe89aa4..3126cbb5b0cb9311492d376b0fa24b411ab9c3e6 100644 (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;