Skip to content

Commit 6cc60b3

Browse files
committed
[GR-40071] String.indexOf is no longer considered PE safe.
PullRequest: fastr/2739
2 parents dadce43 + 840caf5 commit 6cc60b3

File tree

1 file changed

+7
-2
lines changed
  • com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base

1 file changed

+7
-2
lines changed

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/GrepFunctions.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,9 +1210,9 @@ protected Info[] getInfo(String pattern, String text, boolean ignoreCase, boolea
12101210
if (fixed) {
12111211
int index;
12121212
if (ignoreCase) {
1213-
index = toLowerCase(text).indexOf(toLowerCase(pattern));
1213+
index = stringIndexOf(toLowerCase(text), toLowerCase(pattern));
12141214
} else {
1215-
index = text.indexOf(pattern);
1215+
index = stringIndexOf(text, pattern);
12161216
}
12171217
if (index != -1) {
12181218
result = new Info[]{new Info(index + 1, pattern.length(), null, null, null)};
@@ -1232,6 +1232,11 @@ protected Info[] getInfo(String pattern, String text, boolean ignoreCase, boolea
12321232
return new Info[]{new Info(-1, -1, null, null, null)};
12331233
}
12341234

1235+
@TruffleBoundary
1236+
private static int stringIndexOf(String text, String pattern) {
1237+
return text.indexOf(pattern);
1238+
}
1239+
12351240
@TruffleBoundary
12361241
private static boolean find(Matcher m) {
12371242
return m.find();

0 commit comments

Comments
 (0)