Skip to content

Commit 4764913

Browse files
committed
[stdlib] guard against underflow
1 parent 42337d3 commit 4764913

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

stdlib/public/core/Span/OutputSpan.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ extension OutputSpan where Element: ~Copyable {
315315
@_alwaysEmitIntoClient
316316
@lifetime(self: copy self)
317317
public mutating func removeAll() {
318+
guard count > 0 else { return }
318319
_ = unsafe _start().withMemoryRebound(to: Element.self, capacity: _count) {
319320
unsafe $0.deinitialize(count: _count)
320321
}

0 commit comments

Comments
 (0)