Ghidra is a software reverse engineering (SRE) framework
GT-3620 SymbolPathParser review fix
ghizard4478f85650bc
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.javaindex 98cc7bc301..aa3c4d58ca 100644--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/util/SymbolPathParser.java@@ -73,7 +73,7 @@ public class SymbolPathParser {if (endIndex > startIndex) {list.add(name.substring(startIndex, endIndex));startIndex = i + 2;- i++; // Only increment one, because the loop also has in increment.+ i++; // Only increment one, because the loop also has an increment.}}}@@ -100,8 +100,8 @@ public class SymbolPathParser {int endIndex = i; // could be 0 if i == 0.if (endIndex > startIndex) {list.add(name.substring(startIndex, endIndex));- i += 2;- startIndex = i;+ startIndex = i + 2;+ i++; // Only increment one, because the loop also has an increment.}}}diff --git a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.javaindex b294079b80..3ad581be35 100644--- a/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java+++ b/Ghidra/Framework/SoftwareModeling/src/test/java/ghidra/app/util/SymbolPathParserTest.java@@ -130,4 +130,20 @@ public class SymbolPathParserTest extends AbstractGTest {assertListEqualOrdered(expected, list);}+ @Test+ public void testUnmatchedAngleBracketFallback1() {+ // Contrived example to test naive parsing going into fallback mode due to unmatched+ // angle brackets. The expected result here is not an accurate result that we would+ // expect from a more sophisticated parser.+ String name = "A::operator<=::B<C<int>::<unnamed-tag>>::E";+ List<String> list = SymbolPathParser.parse(name);+ List<String> expected = new ArrayList<>();+ expected.add("A");+ expected.add("operator<=");+ expected.add("B<C<int>");+ expected.add("<unnamed-tag>>");+ expected.add("E");+ assertListEqualOrdered(expected, list);+ }+}