From 352e361ea51a68fdb3a403e170157d13e185b47c Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 19 Dec 2024 10:40:59 +0100 Subject: [PATCH] Check for nullptr before resolving inverses --- src/ifcparse/IfcUtil.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ifcparse/IfcUtil.cpp b/src/ifcparse/IfcUtil.cpp index 57008fe260..41289752d0 100644 --- a/src/ifcparse/IfcUtil.cpp +++ b/src/ifcparse/IfcUtil.cpp @@ -231,6 +231,9 @@ AttributeValue IfcUtil::IfcBaseEntity::get(const std::string& name) const } aggregate_of_instance::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const { + if (file_ == nullptr) { + throw IfcParse::IfcException("Instance not added to file"); + } const std::vector attrs = declaration().as_entity()->all_inverse_attributes(); std::vector::const_iterator iter = attrs.begin(); for (; iter != attrs.end(); ++iter) {