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:
Nathan Schulte
2023-10-15 03:13:21 -05:00
committed by emteere
parent d52f314270
commit fc59ad6d8e

View File

@@ -878,10 +878,9 @@ public class DefineTable {
pos = startPos;
int endParen = strValue.indexOf(')', pos + 1);
if (endParen != -1) {
String subStr = strValue.substring(pos + 1, endParen);
String subStr = strValue.substring(pos + 1, endParen).trim();
if (subStr.length() > 0) {
int subPos = 0;
subStr = subStr.trim();
boolean isValid = Character.isJavaIdentifierStart(subStr.charAt(0));
while (isValid && subPos < subStr.length()) {
char ch = subStr.charAt(subPos++);