mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
CParser: prevent crash when parsing
if the trimmed token length is zero, charAt() explodes this is likely a bad macro, but CParser should not crash regardless
This commit is contained in:
@@ -878,10 +878,9 @@ public class DefineTable {
|
|||||||
pos = startPos;
|
pos = startPos;
|
||||||
int endParen = strValue.indexOf(')', pos + 1);
|
int endParen = strValue.indexOf(')', pos + 1);
|
||||||
if (endParen != -1) {
|
if (endParen != -1) {
|
||||||
String subStr = strValue.substring(pos + 1, endParen);
|
String subStr = strValue.substring(pos + 1, endParen).trim();
|
||||||
if (subStr.length() > 0) {
|
if (subStr.length() > 0) {
|
||||||
int subPos = 0;
|
int subPos = 0;
|
||||||
subStr = subStr.trim();
|
|
||||||
boolean isValid = Character.isJavaIdentifierStart(subStr.charAt(0));
|
boolean isValid = Character.isJavaIdentifierStart(subStr.charAt(0));
|
||||||
while (isValid && subPos < subStr.length()) {
|
while (isValid && subPos < subStr.length()) {
|
||||||
char ch = subStr.charAt(subPos++);
|
char ch = subStr.charAt(subPos++);
|
||||||
|
|||||||
Reference in New Issue
Block a user