diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 0b49fe23b..4f70fd0b9 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -381,9 +381,10 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, }); return ^{ - if (cancelLoad && !cancelled) { - cancelLoad(); - cancelLoad = nil; + dispatch_block_t cancelLoadLocal = cancelLoad; + cancelLoad = nil; + if (cancelLoadLocal && !cancelled) { + cancelLoadLocal(); } OSAtomicOr32Barrier(1, &cancelled); }; @@ -515,8 +516,9 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, __block volatile uint32_t cancelled = 0; __block dispatch_block_t cancelLoad = nil; dispatch_block_t cancellationBlock = ^{ - if (cancelLoad && !cancelled) { - cancelLoad(); + dispatch_block_t cancelLoadLocal = cancelLoad; + if (cancelLoadLocal && !cancelled) { + cancelLoadLocal(); } OSAtomicOr32Barrier(1, &cancelled); };