Defensiveness against invalid syntax #5608

This commit is contained in:
Thomas Krijnen
2024-10-20 14:17:13 +02:00
parent 65ecb92c03
commit 18d5957424
+15 -9
View File
@@ -280,13 +280,15 @@ 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>) {
references_to_resolve.push_back(std::make_pair( if (name > 0) {
// @todo previously this was storage but apparently the references_to_resolve.push_back(std::make_pair(
// pointer is not constant with the moving and temporary nature // @todo previously this was storage but apparently the
// maybe it ought to be and in that case a pointer is more direct // pointer is not constant with the moving and temporary nature
MutableAttributeValue{ name, index }, // maybe it ought to be and in that case a pointer is more direct
v MutableAttributeValue{ name, index },
)); 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>>) {
references_to_resolve.push_back({ {name, index }, v }); if (name > 0) {
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>>>) {
references_to_resolve.push_back({ {name, index }, v }); if (name > 0) {
references_to_resolve.push_back({ {name, index }, v });
}
} else { } else {
storage.set(index, v); storage.set(index, v);
} }