Skip to content

Ghidra is a software reverse engineering (SRE) framework

gp-4641 - MDMang fix infinite loop

ghizard2efe1b9e624c
diff --git a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/naming/MDQualification.java b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/naming/MDQualification.java
index 32c686066b..af71cde9aa 100644
--- a/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/naming/MDQualification.java
+++ b/Ghidra/Features/MicrosoftDmang/src/main/java/mdemangler/naming/MDQualification.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.
@@ -97,9 +97,16 @@ public class MDQualification extends MDParsableItem implements Iterable<MDQualif
@Override
protected void parseInternal() throws MDException {
while ((dmang.peek() != MDMang.DONE) && (dmang.peek() != '@')) {
+ int loc = dmang.getIndex();
MDQualifier qual = new MDQualifier(dmang);
qual.parse();
quals.add(qual);
+ // This is a quick fix to prevent infinite looping when the next character is not
+ // expected. TODO: need to work on code the breaks symbols on these other
+ // characters that we have seen such as '.' and '`'.
+ if (dmang.getIndex() == loc) {
+ break;
+ }
}
if (dmang.peek() == '@') {
dmang.increment(); // Skip past @.