Ghidra is a software reverse engineering (SRE) framework
GP-349 - Fixed memory search highlight exception
dragonmacherf30666e4e64d
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.javaindex efbe2b37c0..3096e204a8 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchPlugin.java@@ -373,8 +373,8 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,return !(context instanceof RestrictedAddressSetContext) && searchInfo != null;}};- searchAgainAction.setHelpLocation(- new HelpLocation(HelpTopics.SEARCH, searchAgainAction.getName()));+ searchAgainAction+ .setHelpLocation(new HelpLocation(HelpTopics.SEARCH, searchAgainAction.getName()));menuPath = new String[] { "&Search", "Repeat Memory Search" };searchAgainAction.setMenuBarData(new MenuData(menuPath, "search"));searchAgainAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_F3, 0));@@ -750,14 +750,19 @@ public class MemSearchPlugin extends Plugin implements OptionsChangeListener,private Color getHighlightColor(Address highlightStart, int highlightLength) {ProgramLocation location = navigatable != null ? navigatable.getLocation() : null;- if (location instanceof BytesFieldLocation) {- BytesFieldLocation byteLoc = (BytesFieldLocation) location;- Address byteAddress = byteLoc.getAddressForByte();+ if (!(location instanceof BytesFieldLocation)) {+ return defaultHighlightColor;+ }++ BytesFieldLocation byteLoc = (BytesFieldLocation) location;+ Address byteAddress = byteLoc.getAddressForByte();+ if (highlightStart.hasSameAddressSpace(byteAddress)) {long diff = byteAddress.subtract(highlightStart);if (diff >= 0 && diff < highlightLength) {- return activeHighlightColor;+ return activeHighlightColor; // the current location is in the highlight}}+return defaultHighlightColor;}