From 3744b81ccd8ed1e6d4aa491d82d36452212995de Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 25 Mar 2025 10:15:24 +0100 Subject: [PATCH] Only accept finite floats #6409 --- src/ifcparse/IfcParse.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index d708f6152e..2eec8ea867 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1130,6 +1130,23 @@ class apply_individual_instance_visitor { template void IfcUtil::IfcBaseClass::set_attribute_value(size_t i, const T& t) { + if constexpr (std::is_same_v, double>) { + if (!std::isfinite(t)) { + throw IfcParse::IfcException("Only finite values are allowed"); + } + } + if constexpr (std::is_same_v, std::vector>) { + if (std::any_of(t.begin(), t.end(), [](double d) { return !std::isfinite(d); })) { + throw IfcParse::IfcException("Only finite values are allowed"); + } + } + if constexpr (std::is_same_v, std::vector>>) { + for (auto& tt : t) { + if (std::any_of(tt.begin(), tt.end(), [](double d) { return !std::isfinite(d); })) { + throw IfcParse::IfcException("Only finite values are allowed"); + } + } + } auto current_attribute = data_.get_attribute_value(i); if (file_ != nullptr) {