Skip to content

Commit 8fb4647

Browse files
committed
Bug fix in matching engine for reading subsequences out of bounds
1 parent d0b7d80 commit 8fb4647

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/_MatchingEngine/Engine/Processor.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ extension Processor {
9393
}
9494

9595
extension Processor {
96+
var slice: Input.SubSequence {
97+
// TODO: Should we whole-scale switch to slices, or
98+
// does that depend on options for some anchors?
99+
input[bounds]
100+
}
101+
96102
// Advance in our input
97103
//
98104
// Returns whether the advance succeeded. On failure, our
@@ -125,7 +131,7 @@ extension Processor {
125131
currentPosition < end ? input[currentPosition] : nil
126132
}
127133
func load(count: Int) -> Input.SubSequence? {
128-
let slice = input[currentPosition...].prefix(count)
134+
let slice = self.slice[currentPosition...].prefix(count)
129135
guard slice.count == count else { return nil }
130136
return slice
131137
}

0 commit comments

Comments
 (0)