From 53e8a68c388567b8e03642bd787a4094e7f544fe Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 16 May 2025 00:38:47 +0200 Subject: [PATCH] sequence: avoid exception during XML parsing Issue #5245 --- repos/os/src/app/sequence/main.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/repos/os/src/app/sequence/main.cc b/repos/os/src/app/sequence/main.cc index c6cad30202..22acd318ab 100644 --- a/repos/os/src/app/sequence/main.cc +++ b/repos/os/src/app/sequence/main.cc @@ -225,7 +225,7 @@ struct Sequence::Main Xml_node const config_xml = config_rom.xml(); - int next_xml_index = 0; + unsigned next_xml_index = 0; void start_next_child(); @@ -266,15 +266,20 @@ void Sequence::Main::start_next_child() if (constructed) child.destruct(); - try { while (true) { + bool finished = false; + while (true) { + if (next_xml_index >= config_xml.num_sub_nodes()) { + finished = true; + break; + } Xml_node sub_node = config_xml.sub_node(next_xml_index++); if (sub_node.type() != "start") continue; child.construct(env, sub_node, exit_handler); break; - } } + } - catch (Xml_node::Nonexistent_sub_node) { + if (finished) { if (config_xml.attribute_value("repeat", false)) { next_xml_index = 0;