From fc1f4d8115d5e10b9b082c68e148b37eebde061c Mon Sep 17 00:00:00 2001 From: David Beck Date: Tue, 29 Oct 2024 09:13:36 +0100 Subject: [PATCH] Bugfix for fixedarray --- src/serialize/ParserProcessDefaultValues.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/serialize/ParserProcessDefaultValues.cpp b/src/serialize/ParserProcessDefaultValues.cpp index 78106cff..c0dc2b9c 100644 --- a/src/serialize/ParserProcessDefaultValues.cpp +++ b/src/serialize/ParserProcessDefaultValues.cpp @@ -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) { @@ -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 @@ -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(); }