From 85887b6db08d93ee9901467d6378ed5f20f2dc30 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 11 Apr 2024 20:01:06 +0200 Subject: [PATCH] Clone profile for immutability in IfcDerivedProfileDef --- src/ifcgeom/mapping/IfcDerivedProfileDef.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp b/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp index 6716e300ac..18091d3d2c 100644 --- a/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcDerivedProfileDef.cpp @@ -23,6 +23,11 @@ using namespace ifcopenshell::geometry; taxonomy::ptr mapping::map_impl(const IfcSchema::IfcDerivedProfileDef* inst) { auto it = map(inst->ParentProfile()); + if (it == nullptr) { + return nullptr; + } + // @todo we mutate it so we need to clone otherwise we alter the cached item. + it = taxonomy::item::ptr(it->clone_()); taxonomy::matrix4::ptr m = taxonomy::cast(map(inst->Operator())); if (!taxonomy::cast(it)->matrix) { // @todo should this not be initialized by default? matrix4 already has a 'lazy identity' mechanism.