From 3c9e1ab0ffee3dfc9680c5120ba3035a439939ca Mon Sep 17 00:00:00 2001 From: Alessio Nossa Date: Wed, 10 Dec 2025 18:21:53 +0100 Subject: [PATCH] Check limit bigger than 0 in AsyncShareSequence iterate --- Sources/AsyncAlgorithms/AsyncShareSequence.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/AsyncAlgorithms/AsyncShareSequence.swift b/Sources/AsyncAlgorithms/AsyncShareSequence.swift index ebe3492..7468a08 100644 --- a/Sources/AsyncAlgorithms/AsyncShareSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncShareSequence.swift @@ -426,7 +426,7 @@ where Base.Element: Sendable, Base: SendableMetatype, Base.AsyncIterator: Sendab if let limit { let cancelled = await withUnsafeContinuation { (continuation: UnsafeContinuation) in let (resume, cancelled) = state.withLock { state -> (UnsafeContinuation?, Bool) in - guard state.buffer.count >= limit else { + guard limit > 0, state.buffer.count >= limit else { assert(state.limit == nil) guard case .cancelled = state.iteratingTask else { return (continuation, false)