Defensiveness against invalid syntax #5608

This commit is contained in:
Thomas Krijnen
2024-10-20 14:17:13 +02:00
parent 65ecb92c03
commit 18d5957424
+6
View File
@@ -280,6 +280,7 @@ IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_re
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, IfcParse::Token>) { if constexpr (std::is_same_v<std::decay_t<decltype(v)>, IfcParse::Token>) {
dispatch_token(v, param_type && param_type->as_named_type() ? param_type->as_named_type()->declared_type() : nullptr, [this, &storage, name, &references_to_resolve, index](auto v) { dispatch_token(v, param_type && param_type->as_named_type() ? param_type->as_named_type()->declared_type() : nullptr, [this, &storage, name, &references_to_resolve, index](auto v) {
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, IfcParse::reference_or_simple_type>) { if constexpr (std::is_same_v<std::decay_t<decltype(v)>, IfcParse::reference_or_simple_type>) {
if (name > 0) {
references_to_resolve.push_back(std::make_pair( references_to_resolve.push_back(std::make_pair(
// @todo previously this was storage but apparently the // @todo previously this was storage but apparently the
// pointer is not constant with the moving and temporary nature // pointer is not constant with the moving and temporary nature
@@ -287,6 +288,7 @@ IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_re
MutableAttributeValue{ name, index }, MutableAttributeValue{ name, index },
v v
)); ));
}
} else { } else {
storage.set(index, v); storage.set(index, v);
} }
@@ -300,9 +302,13 @@ IfcEntityInstanceData IfcParse::parse_context::construct(int name, unresolved_re
} }
construct_<0>(*v, pt ? pt->as_aggregation_type() : nullptr, [this, &storage, name, &references_to_resolve, index](const auto& v) { construct_<0>(*v, pt ? pt->as_aggregation_type() : nullptr, [this, &storage, name, &references_to_resolve, index](const auto& v) {
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<reference_or_simple_type>>) { if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<reference_or_simple_type>>) {
if (name > 0) {
references_to_resolve.push_back({ {name, index }, v }); references_to_resolve.push_back({ {name, index }, v });
}
} else if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<std::vector<reference_or_simple_type>>>) { } else if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<std::vector<reference_or_simple_type>>>) {
if (name > 0) {
references_to_resolve.push_back({ {name, index }, v }); references_to_resolve.push_back({ {name, index }, v });
}
} else { } else {
storage.set(index, v); storage.set(index, v);
} }