mirror of
https://github.com/apple/swift-collections
synced 2026-11-30 05:18:44 +00:00
[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:
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)
|
||||
|
||||
Reference in new issue
Block a user