Commit 34e6d45
committed
fix: panic in linear myers algorithm
In `linearSpaceMyersRecWithIndices`, the suffix-scanning loop:
```go
for suffix < n-prefix && a[aEnd-1-suffix] == b[bEnd-1-suffix] {
```
bounds the scan against n-prefix (a's remaining length after prefix) but not against m-prefix (b's remaining length).
With the fuzzer's input a="\n\n\n\n\n\n\n\n\n0" → 10 lines, b="0" → 1 line:
n=10, m=1, prefix=0
suffix=0: a[9]="0" == b[0]="0" → true, suffix becomes 1
suffix=1: tries b[1-1-1] = b[-1] → index out of range panic
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>1 parent a1f8b87 commit 34e6d45
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
0 commit comments