Skip to content

Commit

Permalink
Only offer element nodes in element_first_child and element_next
Browse files Browse the repository at this point in the history
Required because children contains other node types.

This matches the behaviour of the next_entity interface, and is safe
because existing callers (all in gvmd manage_sql_secinfo.c) always
check the node name.
  • Loading branch information
mattmundell committed May 8, 2023
1 parent fcacebd commit 0fb3f80
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions util/xmlutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,12 @@ element_attribute (element_t element, const gchar *name)
element_t
element_first_child (element_t element)
{
if (element)
return element->children;
if (element) {
element = element->children;
while (element && (element->type != XML_ELEMENT_NODE))
element = element->next;
return element;
}
return NULL;
}

Expand All @@ -2046,8 +2050,12 @@ element_first_child (element_t element)
element_t
element_next (element_t element)
{
if (element)
return element->next;
if (element) {
element = element->next;
while (element && (element->type != XML_ELEMENT_NODE))
element = element->next;
return element;
}
return NULL;
}

Expand Down

0 comments on commit 0fb3f80

Please sign in to comment.