[PATCH 2/4] conf: plug memory leaks

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

 



* src/conf/domain_conf.c (virDomainGraphicsDefParseXML)
(virDomainDeviceVirtioSerialAddressParseXML)
(virDomainDiskDefFree): Free various leaks.
---

All real leaks in libvirt, and all present in 0.8.6 (if not earlier).

 src/conf/domain_conf.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5b0fd55..d516fbe 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -524,6 +524,7 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)

     for (i = 0 ; i < def->nhosts ; i++)
         virDomainDiskHostDefFree(&def->hosts[i]);
+    VIR_FREE(def->hosts);

     VIR_FREE(def);
 }
@@ -1420,6 +1421,7 @@ virDomainDeviceVirtioSerialAddressParseXML(
 cleanup:
     VIR_FREE(controller);
     VIR_FREE(bus);
+    VIR_FREE(port);
     return ret;
 }

@@ -3491,6 +3493,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
                     if (!name || !mode) {
                         virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                                              _("spice channel missing name/mode"));
+                        VIR_FREE(name);
+                        VIR_FREE(mode);
                         goto error;
                     }

@@ -3498,14 +3502,20 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
                         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                              _("unknown spice channel name %s"),
                                              name);
+                        VIR_FREE(name);
+                        VIR_FREE(mode);
                         goto error;
                     }
                     if ((modeval = virDomainGraphicsSpiceChannelModeTypeFromString(mode)) < 0) {
                         virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                                              _("unknown spice channel mode %s"),
                                              mode);
+                        VIR_FREE(name);
+                        VIR_FREE(mode);
                         goto error;
                     }
+                    VIR_FREE(name);
+                    VIR_FREE(mode);

                     def->data.spice.channels[nameval] = modeval;
                 }
-- 
1.7.3.2

--
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]