Skip to content

Commit 26235e9

Browse files
committed
fix: check path attribute before using
1 parent 8d47d39 commit 26235e9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/xml_parsing.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,15 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes)
261261
break;
262262
}
263263

264+
const char* path_attr = incl_node->Attribute("path");
265+
if (!path_attr) {
266+
throw RuntimeError("Invalid <include> tag: missing 'path' attribute");
267+
}
268+
264269
#if __bt_cplusplus >= 202002L
265-
auto file_path(std::filesystem::path(incl_node->Attribute("path")));
270+
auto file_path{ std::filesystem::path(path_attr) };
266271
#else
267-
auto file_path(std::filesystem::u8path(incl_node->Attribute("path")));
272+
auto file_path{ std::filesystem::u8path(path_attr) };
268273
#endif
269274

270275
const char* ros_pkg_relative_path = incl_node->Attribute("ros_pkg");

0 commit comments

Comments
 (0)