mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
domain: avoid potential memory leak in virDomainGraphicsListenSet*()
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.
This commit is contained in:
parent
699299419b
commit
6d1194ffc0
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user