diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesBySizeAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesBySizeAction.java index 43fb93b079..5d0f4bf95e 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesBySizeAction.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesBySizeAction.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -92,6 +92,10 @@ public class FindDataTypesBySizeAction extends DockingAction { DataTypeNode dataTypeNode = (DataTypeNode) node; DataType dt = dataTypeNode.getDataType(); int length = dt.getLength(); + if (dt.isZeroLength()) { + length = 0; + } + for (Range range : sizes) { if (range.contains(length)) { return true; diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindStructuresBySizeAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindStructuresBySizeAction.java index 75127c62a1..fdb230ec93 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindStructuresBySizeAction.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindStructuresBySizeAction.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -70,6 +70,10 @@ public class FindStructuresBySizeAction extends FindDataTypesBySizeAction { Structure structure = (Structure) dataType; int length = structure.getLength(); + if (structure.isZeroLength()) { + length = 0; + } + for (Range range : sizes) { if (range.contains(length)) { return true; diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java index daf57fa82f..e18720aae2 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java @@ -852,6 +852,25 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe assertMatchingStructures(resultsProvider, "Structure_0x8"); } + @Test + public void testAction_FindStructureBySize_Empty() { + + StructureDataType stuct = new StructureDataType("Structure_Empty", 0); + builder.addDataType(stuct); + + DockingActionIf action = getAction(plugin, FindStructuresBySizeAction.NAME); + performAction(action, false); + + NumberRangeInputDialog dialog = waitForDialogComponent(NumberRangeInputDialog.class); + setText(dialog, "0"); + + pressButtonByText(dialog, "OK"); + + DataTypesProvider resultsProvider = + waitForComponentProvider(DataTypesProvider.class, FindStructuresBySizeAction.NAME); + assertMatchingStructures(resultsProvider, "Structure_Empty"); + } + @Test public void testAction_FindStructureBySize_Ranage() {