More resiliance against wrong attribute counts

This commit is contained in:
Thomas Krijnen
2022-10-03 14:05:08 +02:00
parent 698c708bf6
commit ca5249a179
+11 -3
View File
@@ -744,16 +744,24 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en
}
if (vector) {
attributes = new Argument*[vector->size()];
return_value = vector->size();
// @todo figure out whether all this logic is still necessary, since we know the
// expected amount of attributes and shouldn't be able to access more than allowed
// by the schema.
attributes = new Argument*[(std::max)(num_attributes, vector->size())]{ nullptr };
// @todo this appears unnecessary, we increment this in the loop already,
// which is more accurate as the filler can't go above it's size in case
// it uses the pre-allocated c-array.
// -> return_value = vector->size();
for (size_t i = 0; i < vector->size(); ++i) {
attributes[i] = vector->at(i);
}
}
if (vector != &internal_attribute_vector_) {
delete vector;
}
}
return return_value;
}