[wpiutil] Fix dynamic struct decoding for nested structs (#7346)

After a struct-type field descriptor had offsets calculated more than once, IsBitField would return true, causing the second call to CalculateOffsets to calculate incorrect offsets.
This commit is contained in:
Ryan Blue
2024-11-05 08:43:04 -05:00
committed by GitHub
parent 8588b5e520
commit 7a6c7af412
5 changed files with 54 additions and 10 deletions

View File

@@ -10,6 +10,7 @@
#include <span>
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -234,7 +235,8 @@ class StructFieldDescriptor {
* @return true if bitfield
*/
bool IsBitField() const {
return m_bitShift != 0 || m_bitWidth != (m_size * 8);
return (m_bitShift != 0 || m_bitWidth != (m_size * 8)) &&
m_struct == nullptr;
}
private: