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 <mpriv...@redhat.com>
---
 src/conf/domain_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fdf5ad19e..b6ebe918d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -22910,10 +22910,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;
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to