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) {