[PATCH 5/8] virVMXParseConfig: Don't leak def->videos

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function calls virDomainDefAddImplicitDevices() which adds
implicit video device to domain definition. However, later in the
process the function just ignores this and overwrites the @videos
array without prior free.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/vmx/vmx.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 96507f10f..858bc090d 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1305,6 +1305,7 @@ virVMXParseConfig(virVMXContext *ctx,
     long long sharedFolder_maxNum = 0;
     int cpumasklen;
     char *namespaceData;
+    size_t i;
 
     if (ctx->parseFileName == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1761,11 +1762,13 @@ virVMXParseConfig(virVMXContext *ctx,
     /* FIXME */
 
     /* def:videos */
-    if (VIR_ALLOC_N(def->videos, 1) < 0)
-        goto cleanup;
-
+    for (i = 0; i < def->nvideos; i++)
+        virDomainVideoDefFree(def->videos[i]);
     def->nvideos = 0;
 
+    if (VIR_REALLOC_N(def->videos, 1) < 0)
+        goto cleanup;
+
     if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0)
         goto cleanup;
 
-- 
2.13.0

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux