mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
virNetworkDHCPRangeDefParseXML: Use virXMLNodeGetSubelement to find 'lease'
This also prevents a potential memleak when multiple elements would be present. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
4088b5afa3
commit
7bd0e8674c
@ -453,7 +453,7 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
|
||||
virNetworkDHCPRangeDef *range)
|
||||
{
|
||||
virSocketAddrRange *addr = &range->addr;
|
||||
xmlNodePtr cur = node->children;
|
||||
xmlNodePtr lease;
|
||||
g_autofree char *start = NULL;
|
||||
g_autofree char *end = NULL;
|
||||
|
||||
@ -480,15 +480,9 @@ virNetworkDHCPRangeDefParseXML(const char *networkName,
|
||||
virNetworkIPDefPrefix(ipdef)) < 0)
|
||||
return -1;
|
||||
|
||||
while (cur != NULL) {
|
||||
if (cur->type == XML_ELEMENT_NODE &&
|
||||
virXMLNodeNameEqual(cur, "lease")) {
|
||||
|
||||
if (virNetworkDHCPLeaseTimeDefParseXML(&range->lease, cur) < 0)
|
||||
return -1;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
if ((lease = virXMLNodeGetSubelement(node, "lease")) &&
|
||||
virNetworkDHCPLeaseTimeDefParseXML(&range->lease, lease) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user