mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
#2358 fix header entity parsing in case of too few fields
This commit is contained in:
@@ -1094,11 +1094,7 @@ void IfcEntityInstanceData::load() const {
|
|||||||
static std::recursive_mutex m;
|
static std::recursive_mutex m;
|
||||||
std::lock_guard<std::recursive_mutex> lk(m);
|
std::lock_guard<std::recursive_mutex> lk(m);
|
||||||
|
|
||||||
// type_ is 0 for header entities which have their size predetermined in code
|
|
||||||
Argument** tmp_data = nullptr;
|
Argument** tmp_data = nullptr;
|
||||||
if (type_ != 0) {
|
|
||||||
tmp_data = new Argument*[getArgumentCount()]{};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file->parsing_complete()) {
|
if (file->parsing_complete()) {
|
||||||
// only when parsing is fully complete we need to seek to the instance, otherwise
|
// only when parsing is fully complete we need to seek to the instance, otherwise
|
||||||
@@ -1109,13 +1105,18 @@ void IfcEntityInstanceData::load() const {
|
|||||||
file->tokens->Next();
|
file->tokens->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = file->load(id(), type_ ? type_->as_entity() : nullptr, tmp_data, getArgumentCount());
|
// type_ is 0 for header entities which have their size predetermined in code
|
||||||
|
// in that we have attributes_ pre-constructed to the correct size in the constructor
|
||||||
|
// in the other case load() will use a vector internally to grow to the size found in the file
|
||||||
|
size_t n = file->load(id(), type_ ? type_->as_entity() : nullptr, type_ ? tmp_data : attributes_, getArgumentCount());
|
||||||
if (n != getArgumentCount()) {
|
if (n != getArgumentCount()) {
|
||||||
Logger::Error("Wrong number of attributes on instance with id #" + boost::lexical_cast<std::string>(id_));
|
Logger::Error("Wrong number of attributes on instance with id #" + boost::lexical_cast<std::string>(id_));
|
||||||
}
|
}
|
||||||
file->try_read_semicolon();
|
file->try_read_semicolon();
|
||||||
// @todo does this need to be atomic somehow?
|
// @todo does this need to be atomic somehow?
|
||||||
attributes_ = tmp_data;
|
if (tmp_data) {
|
||||||
|
attributes_ = tmp_data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
Reference in New Issue
Block a user