Skip to content

Commit

Permalink
Bugfix for fixedarray
Browse files Browse the repository at this point in the history
  • Loading branch information
beckdave committed Oct 29, 2024
1 parent 7694071 commit fc1f4d8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/serialize/ParserProcessDefaultValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void ParserProcessDefaultValues::enterStruct(const MetaField& field)
if (!m_stackArrayStructState.empty())
{
EntryArrayStructState& arrayStructState = m_stackArrayStructState.back();
if (arrayStructState.level == 0)
if ((arrayStructState.fixedSize != -1) && (arrayStructState.level == 0))
{
if (arrayStructState.numberOfArrayEntries < arrayStructState.fixedSize)
{
Expand Down Expand Up @@ -401,12 +401,13 @@ void ParserProcessDefaultValues::enterArrayStruct(const MetaField& field)
markAsDone(field);
if (!m_skipDefaultValues)
{
int fixedSize = -1;
const std::string& fixedArray = field.getProperty(FIXED_ARRAY);
if (!fixedArray.empty())
{
const int fixedSize = atoi(fixedArray.c_str());
m_stackArrayStructState.push_back({ fixedSize, 0, 0 });
fixedSize = atoi(fixedArray.c_str());
}
m_stackArrayStructState.push_back({ fixedSize, 0, 0 });
m_visitor->enterArrayStruct(field);
}
else
Expand All @@ -433,11 +434,14 @@ void ParserProcessDefaultValues::exitArrayStruct(const MetaField& field)
{
const EntryArrayStructState& entry = m_stackArrayStructState.back();
const int fixedSize = entry.fixedSize;
const int currentSize = entry.numberOfArrayEntries;
for (int i = currentSize; i < fixedSize; ++i)
if (fixedSize != -1)
{
enterStruct(*field.fieldWithoutArray);
exitStruct(*field.fieldWithoutArray);
const int currentSize = entry.numberOfArrayEntries;
for (int i = currentSize; i < fixedSize; ++i)
{
enterStruct(*field.fieldWithoutArray);
exitStruct(*field.fieldWithoutArray);
}
}
m_stackArrayStructState.pop_back();
}
Expand Down

0 comments on commit fc1f4d8

Please sign in to comment.