[libvirt] [PATCH 3/6] domain_conf: Resolve Coverity RESOURCE_LEAK

John Ferlan jferlan at redhat.com
Fri Jan 9 16:02:04 UTC 2015


Commit id's 'c9a641f1e' and 'aa2cc721' added calls to virSocketAddrFormat
and did not VIR_FREE() the return memory.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/domain_conf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d1a483a..b53cb8d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17270,6 +17270,7 @@ virDomainNetIpsFormat(virBufferPtr buf, virDomainNetIpDefPtr *ips, size_t nips)
             familyStr = "ipv4";
         virBufferAsprintf(buf, "<ip address='%s'",
                           ipStr);
+        VIR_FREE(ipStr);
         if (familyStr)
             virBufferAsprintf(buf, " family='%s'", familyStr);
         if (ips[i]->prefix != 0)
@@ -17296,10 +17297,12 @@ virDomainNetRoutesFormat(virBufferPtr buf,
         else if (VIR_SOCKET_ADDR_IS_FAMILY(&route->via, AF_INET))
             familyStr = "ipv4";
         virBufferAsprintf(buf, "<route family='%s' via='%s'", familyStr, via);
+        VIR_FREE(via);
 
         if (VIR_SOCKET_ADDR_VALID(&route->to)) {
             to = virSocketAddrFormat(&route->to);
             virBufferAsprintf(buf, " address='%s'", to);
+            VIR_FREE(to);
         }
 
         if (route->prefix > 0)
-- 
2.1.0




More information about the libvir-list mailing list