[PATCH 2/2] domain: avoid potential memory leak in virDomainGraphicsListenSet*()

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

 



virDomainGraphicsListenSetAddress() and
virDomainGraphicsListenSetNetwork() both set their respective char* to
NULL directly when asked to set it to NULL, which is okay as long as
it's already set to NULL. If these functions are ever called to clear
a listen object that has a valid string in address or network, it will
end up leaking the old value. Currently that doesn't happen, so this
is just a preemptive strike.
---
 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 6614fb1..8600eff 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21440,7 +21440,7 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
         listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
 
     if (!address) {
-        listenInfo->address = NULL;
+        VIR_FREE(listenInfo->address);
         return 0;
     }
 
@@ -21478,7 +21478,7 @@ virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
     listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK;
 
     if (!network) {
-        listenInfo->network = NULL;
+        VIR_FREE(listenInfo->network);
         return 0;
     }
 
-- 
2.1.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]