[RigidArray, RigidDeque].nextSpan: Validate maximumCount

`nextSpan(after:,maximumCount:)` failed to validate that `maximumCount > 0`, potentially allowing out-of-bounds access.
This commit is contained in:
Karoy Lorentey committed 2026-02-16 15:54:49 -08:00
1 parent a446b47d6e
commit ac7a8bf61b
2 files changed
+3 -1

No files matched your search

@@ -94,6 +94,7 @@ extension RigidDeque where Element: ~Copyable {
@_lifetime(borrow self)
public func nextSpan(after index: inout Int, maximumCount: Int) -> Span<Element> {
precondition(index >= 0 && index <= count, "Index out of bounds")
precondition(maximumCount > 0, "maximumCount must be positive")
let segment = self._handle
.nextSegment(from: index)
._extracting(first: maximumCount)