Skip to content

Commit 524c484

Browse files
committed
jbmc-strings/VerifStringLastIndexOf: ensure index is within String
The reference implementation and the built-in function disagree in case the index is out of bounds.
1 parent 4ac7858 commit 524c484

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed
Binary file not shown.

jbmc/regression/jbmc-strings/VerifStringLastIndexOf/Test.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public int referenceLastIndexOf(String s, char ch, int fromIndex) {
1919
}
2020

2121
public int check(String s, char ch, int fromIndex) {
22+
if(s.length() <= fromIndex)
23+
return -1;
2224
int reference = referenceLastIndexOf(s, ch, fromIndex);
2325
int jbmc_result = s.lastIndexOf(ch, fromIndex);
2426
assert(reference == jbmc_result);

0 commit comments

Comments
 (0)