Skip to content

Commit 6731c51

Browse files
ahuo1GodGun123
andauthored
fix: check path attribute before using (#1005)
Co-authored-by: ahuo <[email protected]>
1 parent 8d47d39 commit 6731c51

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/xml_parsing.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,16 @@ 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+
{
267+
throw RuntimeError("Invalid <include> tag: missing 'path' attribute");
268+
}
269+
264270
#if __bt_cplusplus >= 202002L
265-
auto file_path(std::filesystem::path(incl_node->Attribute("path")));
271+
auto file_path{ std::filesystem::path(path_attr) };
266272
#else
267-
auto file_path(std::filesystem::u8path(incl_node->Attribute("path")));
273+
auto file_path{ std::filesystem::u8path(path_attr) };
268274
#endif
269275

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

0 commit comments

Comments
 (0)