mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
conf: Avoid NULL dereference in virDomainNetPortForwardFree
In our current code the function is not called with NULL argument, but we should follow our common practice and make it safe anyway. Reported by coverity: /src/conf/domain_conf.c: 2635 in virDomainNetPortForwardFree() 2629 { 2630 size_t i; 2631 2632 if (pf) 2633 g_free(pf->dev); 2634 >>> CID 404359: Null pointer dereferences (FORWARD_NULL) >>> Dereferencing null pointer "pf". 2635 for (i = 0; i < pf->nRanges; i++) 2636 g_free(pf->ranges[i]); 2637 2638 g_free(pf->ranges); 2639 g_free(pf); 2640 } Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
f0a514dbba
commit
a82d74dd75
@ -2629,8 +2629,10 @@ virDomainNetPortForwardFree(virDomainNetPortForward *pf)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (pf)
|
||||
g_free(pf->dev);
|
||||
if (!pf)
|
||||
return;
|
||||
|
||||
g_free(pf->dev);
|
||||
|
||||
for (i = 0; i < pf->nRanges; i++)
|
||||
g_free(pf->ranges[i]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user