Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit ecef8ed

Browse files
chrisdanfordAdlai Holler
authored andcommitted
Add locking around setting weakCacheEntry ivar (#2812)
1 parent 3506cec commit ecef8ed

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

AsyncDisplayKit/ASImageNode.mm

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ - (UIImage *)displayWithParameters:(id<NSObject> *)parameter isCancelled:(asdisp
379379
if (entry == nil) { // If nil, we were cancelled.
380380
return nil;
381381
}
382-
_weakCacheEntry = entry; // Retain so that the entry remains in the weak cache
382+
383+
__instanceLock__.lock();
384+
_weakCacheEntry = entry; // Retain so that the entry remains in the weak cache
385+
__instanceLock__.unlock();
386+
383387
return entry.value;
384388
}
385389

@@ -523,9 +527,11 @@ - (void)setNeedsDisplayWithCompletion:(void (^ _Nullable)(BOOL canceled))display
523527

524528
- (void)clearContents
525529
{
526-
[super clearContents];
530+
[super clearContents];
527531

532+
__instanceLock__.lock();
528533
_weakCacheEntry = nil; // release contents from the cache.
534+
__instanceLock__.unlock();
529535
}
530536

531537
#pragma mark - Cropping

0 commit comments

Comments
 (0)