mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 08:25:38 +00:00
os: Handle corner case in Xml_node::sub_node
When calling 'sub_node' on a node with no sub nodes, the Xml_node would interpret the characters after the current node while searching for sub nodes. The patch adds a sanity check that lets the 'sub_node' function throw an exception when called on a node with no sub nodes.
This commit is contained in:
parent
65e73074d9
commit
76ecfff7b6
@ -621,6 +621,8 @@ namespace Genode {
|
||||
*/
|
||||
Xml_node sub_node(unsigned idx = 0U) const
|
||||
{
|
||||
if (_num_sub_nodes > 0) {
|
||||
|
||||
/* look up node at specified index */
|
||||
try {
|
||||
Xml_node curr_node = _sub_node(content_addr());
|
||||
@ -628,6 +630,7 @@ namespace Genode {
|
||||
curr_node = curr_node.next();
|
||||
return curr_node;
|
||||
} catch (Invalid_syntax) { }
|
||||
}
|
||||
|
||||
throw Nonexistent_sub_node();
|
||||
}
|
||||
@ -639,6 +642,8 @@ namespace Genode {
|
||||
*/
|
||||
Xml_node sub_node(const char *type) const
|
||||
{
|
||||
if (_num_sub_nodes > 0) {
|
||||
|
||||
/* search for sub node of specified type */
|
||||
try {
|
||||
Xml_node curr_node = _sub_node(content_addr());
|
||||
@ -646,6 +651,7 @@ namespace Genode {
|
||||
if (curr_node.has_type(type))
|
||||
return curr_node;
|
||||
} catch (...) { }
|
||||
}
|
||||
|
||||
throw Nonexistent_sub_node();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user