Skip to content

Commit

Permalink
fix: memory leak by weakly capturing deferred object
Browse files Browse the repository at this point in the history
  • Loading branch information
amanjeetsingh150 committed Dec 25, 2023
1 parent 3d64eb4 commit 8942da8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ThirdParty/Deferred/Deferred/Deferred.swift
Expand Up @@ -133,10 +133,10 @@ public func all<T>(_ deferreds: [Deferred<T>]) -> Deferred<[T]> {
results.reserveCapacity(deferreds.count)

var block: ((T) -> ())!
block = { t in
block = { [weak combined] t in
results.append(t)
if results.count == deferreds.count {
combined.fill(results)
combined?.fill(results)
} else {
deferreds[results.count].upon(block)
}
Expand Down

0 comments on commit 8942da8

Please sign in to comment.