]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain: avoid potential memory leak in virDomainGraphicsListenSet*()
authorLaine Stump <laine@laine.org>
Tue, 10 Feb 2015 19:04:40 +0000 (14:04 -0500)
committerLaine Stump <laine@laine.org>
Wed, 11 Feb 2015 16:05:35 +0000 (11:05 -0500)
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

index 1e439039141f7c3bf7401f964fb8d15c3519d580..32668d43376e29a0cf3265d3a88ccd86c7dab32e 100644 (file)
@@ -21449,7 +21449,7 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
         listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
 
     if (!address) {
-        listenInfo->address = NULL;
+        VIR_FREE(listenInfo->address);
         return 0;
     }
 
@@ -21487,7 +21487,7 @@ virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
     listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK;
 
     if (!network) {
-        listenInfo->network = NULL;
+        VIR_FREE(listenInfo->network);
         return 0;
     }