diff --git a/src/ifcparse/IfcEntityInstanceData.h b/src/ifcparse/IfcEntityInstanceData.h index 15f8a563e0..1719606ab1 100644 --- a/src/ifcparse/IfcEntityInstanceData.h +++ b/src/ifcparse/IfcEntityInstanceData.h @@ -52,8 +52,12 @@ public: {} IfcEntityInstanceData(const IfcParse::declaration* type) - : file(0), id_(0), type_(type), attributes_(0) - {} + : file(0), id_(0), type_(type), attributes_(new Argument*[getArgumentCount()]) + { + for (size_t i = 0; i < getArgumentCount(); ++i) { + attributes_[i] = 0; + } + } void load() const; diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 0f2199636f..06ebb5c57c 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -543,13 +543,10 @@ static const std::string& helper_fn_declaration_get_name(const IfcParse::declara const IfcParse::schema_definition* schema = IfcParse::schema_by_name(schema_identifier); const IfcParse::declaration* decl = schema->declaration_by_name(name); IfcEntityInstanceData* data = new IfcEntityInstanceData(decl); - - size_t attr_count = 1; - if (decl->as_entity()) { - attr_count = decl->as_entity()->attribute_count(); - } - data->setArgument(attr_count - 1, new IfcWrite::IfcWriteArgument()); + for (size_t i = 0; i < data->getArgumentCount(); ++i) { + data->setArgument(i, new IfcWrite::IfcWriteArgument()); + } if (decl->as_entity()) { const std::vector& derived = decl->as_entity()->derived();