Skip to content

Commit a6af872

Browse files
Kolpatimfel
authored andcommitted
fixing a bug that breaks startswith in byte arrays
1 parent ddf7583 commit a6af872

File tree

1 file changed

+6
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesNodes.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,14 @@ int find(PIBytesLike primary, PIBytesLike sub, Object starting, Object ending) {
224224
// TODO implement a more efficient algorithm
225225
outer: for (int i = start; i < end; i++) {
226226
for (int j = 0; j < len2; j++) {
227+
if (i + j >= end) {
228+
continue outer;
229+
}
230+
227231
int hb = getGetLeftItemNode().executeInt(haystack, i + j);
228232
int nb = getGetRightItemNode().executeInt(needle, j);
229-
if (nb != hb || i + j >= end) {
233+
234+
if (nb != hb) {
230235
continue outer;
231236
}
232237
}

0 commit comments

Comments
 (0)