Skip to content

Commit d282ec7

Browse files
authored
Add assertion for index 'a' in suffix array
Add assertion to ensure 'a' is within bounds before accessing 'y'.
1 parent a637445 commit d282ec7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/strings/suffix_array/suffix_array_short.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ auto sa_short(const auto& s) {
2323
int a = i1 + j * k < n ? x[i1 + j * k] : -1;
2424
int b = i2 + j * k < n ? x[i2 + j * k] : -1;
2525
if (a != b) {
26-
if (a != -1) val += y[a];
26+
if (a != -1) assert(a<n-1),val += y[a];
2727
else val = n - i1;
2828
return a < b;
2929
}

0 commit comments

Comments
 (0)