Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-2097 - fix to prevent exception when making a selection that contains a wrapped Decompiler line

dragonmacherb2dd0b69549a
diff --git a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java
index 6a9a947cb4..cbb2128917 100644
--- a/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java
+++ b/Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java
@@ -486,9 +486,18 @@ public class DecompilerUtils {
if (lineNumber >= lines.length) {
return;
}
+
ClangTextField textLine = (ClangTextField) lines[lineNumber];
int startIndex = getStartIndex(textLine, start);
int endIndex = getEndIndex(textLine, end);
+ if (startIndex >= endIndex) {
+ // There is a bug in how the start and end field location get created when a line
+ // wraps. This is likely something we can fix if we can get an example that shows this
+ // state. For now, we are adding this error checking to prevent an exception in the
+ // call below.
+ return;
+ }
+
tokenList.addAll(textLine.getTokens().subList(startIndex, endIndex));
}