-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path3741-Set-isValid-to-false-if-Character.isJavaIdentif.patch
More file actions
43 lines (39 loc) · 1.99 KB
/
Copy path3741-Set-isValid-to-false-if-Character.isJavaIdentif.patch
File metadata and controls
43 lines (39 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Wiz <95232096+GameCubeGBA@users.noreply.github.com>
Date: Fri, 10 Dec 2021 13:06:09 -0500
Subject: [PATCH] 3741: Set isValid to false if
Character.isJavaIdentifierPart(ch) is false
This looks like a mistake. The reason why it does is because the loop will only run if it is valid, and once isValid is true, |= means it will never be false, when it runs, meaning the check does nothing.
Instead, let's iterate over the string and if a character is invalid, the entire string is not an identifier
---
.../ghidra/app/util/cparser/CPP/DefineTable.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/CPP/DefineTable.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/CPP/DefineTable.java
index c84c90e05d..c2ca83ecf1 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/CPP/DefineTable.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/cparser/CPP/DefineTable.java
@@ -879,14 +879,15 @@ public class DefineTable {
int endParen = strValue.indexOf(')', pos + 1);
if (endParen != -1) {
String subStr = strValue.substring(pos + 1, endParen).trim();
- if (subStr.length() > 0) {
- int subPos = 0;
- boolean isValid = Character.isJavaIdentifierStart(subStr.charAt(0));
- while (isValid && subPos < subStr.length()) {
- char ch = subStr.charAt(subPos++);
- isValid |= Character.isJavaIdentifierPart(ch);
+ if (!subStr.isEmpty()) {
+ boolean isValid = true;
+ for (int subPos = 0; subPos < subStr.length(); subPos++) {
+ if (!Character.isJavaIdentifierStart(subStr.charAt(subPos))) {
+ isValid = false;
+ break;
+ }
}
- // if looks like a cast, throw it away
+ // if it looks like a cast, throw it away
if (isValid) {
strValue = strValue.substring(0, pos) + strValue.substring(endParen + 1);
procLen = 0;
--
2.45.1