diff --git a/Libraries/Image/RCTImageLoader.m b/Libraries/Image/RCTImageLoader.m index 0b49fe23b06e60..4f70fd0b9b4232 100644 --- a/Libraries/Image/RCTImageLoader.m +++ b/Libraries/Image/RCTImageLoader.m @@ -381,9 +381,10 @@ - (RCTImageLoaderCancellationBlock)_loadImageOrDataWithURLRequest:(NSURLRequest }); 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 @@ - (RCTImageLoaderCancellationBlock)loadImageWithURLRequest:(NSURLRequest *)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); };