mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
More resiliance against wrong attribute counts
This commit is contained in:
@@ -744,16 +744,24 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vector) {
|
if (vector) {
|
||||||
attributes = new Argument*[vector->size()];
|
// @todo figure out whether all this logic is still necessary, since we know the
|
||||||
return_value = vector->size();
|
// 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) {
|
for (size_t i = 0; i < vector->size(); ++i) {
|
||||||
attributes[i] = vector->at(i);
|
attributes[i] = vector->at(i);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (vector != &internal_attribute_vector_) {
|
if (vector != &internal_attribute_vector_) {
|
||||||
delete vector;
|
delete vector;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user