GT-3032 exclude flexible array component from list of components passed

to structure packer
This commit is contained in:
ghidra1
2019-07-24 19:27:14 -04:00
parent 7b2d94b3f0
commit 8c689a0099
2 changed files with 3 additions and 6 deletions

View File

@@ -59,8 +59,7 @@ class AlignedComponentPacker {
* @param isLastComponent true if dtc is the last component within the structure
*/
void addComponent(InternalDataTypeComponent dtc, boolean isLastComponent) {
if (dtc.getDataType() == DataType.DEFAULT ||
(dtc.isFlexibleArrayComponent() && !isLastComponent)) {
if (dtc.getDataType() == DataType.DEFAULT || dtc.isFlexibleArrayComponent()) {
throw new IllegalArgumentException("unsupported component");
}
if (!packComponent(dtc)) {

View File

@@ -26,7 +26,8 @@ import ghidra.util.exception.DuplicateNameException;
/**
* <code>AlignedStructureInspector</code> provides a simple instance of a structure
* member container used to perform alignment operations without forcing modification
* of the actual structure.
* of the actual structure. A wrapper is not used for the flexible array component
* which will not be modified by packer.
*/
public class AlignedStructureInspector extends AlignedStructurePacker {
@@ -39,9 +40,6 @@ public class AlignedStructureInspector extends AlignedStructurePacker {
for (DataTypeComponent c : structure.getComponents()) {
list.add(new ReadOnlyComponentWrapper(c));
}
if (structure.hasFlexibleArrayComponent()) {
list.add(new ReadOnlyComponentWrapper(structure.getFlexibleArrayComponent()));
}
return list;
}