Skip to content

Commit

Permalink
Fixes initialization issues in IfcEntityInstanceData constructors
Browse files Browse the repository at this point in the history
attributes_ was allocated as an array of Argument pointers but the pointers were uninitialized in the construction. Initialization was done in the HeaderEntity class constructor.

offset_in_file_ is uninitialized in one constructor
  • Loading branch information
RickBrice authored and aothms committed Apr 18, 2021
1 parent 6c8858e commit 75040b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 5 additions & 9 deletions src/ifcparse/IfcEntityInstanceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,13 @@ class IFC_PARSE_API IfcEntityInstanceData {
: file(file_), id_(id), type_(type), attributes_(0), offset_in_file_(offset_in_file)
{}

IfcEntityInstanceData(IfcParse::IfcFile* file_, size_t size)
: file(file_), id_(0), type_(0), attributes_(new Argument*[size]), offset_in_file_(0)
IfcEntityInstanceData(IfcParse::IfcFile* file_, size_t size)
: file(file_), id_(0), type_(0), attributes_(new Argument*[size] {0}), offset_in_file_(0)
{}

IfcEntityInstanceData(const IfcParse::declaration* type)
: file(0), id_(0), type_(type), attributes_(new Argument*[getArgumentCount()])
{
for (size_t i = 0; i < getArgumentCount(); ++i) {
attributes_[i] = 0;
}
}
IfcEntityInstanceData(const IfcParse::declaration* type)
: file(0), id_(0), type_(type), attributes_(new Argument*[getArgumentCount()]{ 0 }), offset_in_file_(0)
{}

void load() const;

Expand Down
5 changes: 0 additions & 5 deletions src/ifcparse/IfcSpfHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ HeaderEntity::HeaderEntity(const char * const datatype, size_t size, IfcFile* fi
if (file) {
offset_in_file_ = file->stream->Tell();
load();
} else {
// attributes_ = new Argument*[size];
for (size_t i = 0; i < size; ++i) {
attributes_[i] = 0;
}
}
}

Expand Down

0 comments on commit 75040b6

Please sign in to comment.