From 384b2d7c8be97bb52eed789662b4b97f5a58ab17 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Fri, 11 Nov 2022 14:22:49 +0800 Subject: [PATCH] Fix the missing lock for callbackTokens which may cause thread-safe issue --- SDWebImage/Core/SDWebImageDownloaderOperation.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SDWebImage/Core/SDWebImageDownloaderOperation.m b/SDWebImage/Core/SDWebImageDownloaderOperation.m index 837883e2..3c0c8abd 100644 --- a/SDWebImage/Core/SDWebImageDownloaderOperation.m +++ b/SDWebImage/Core/SDWebImageDownloaderOperation.m @@ -244,7 +244,10 @@ self.coderQueue.qualityOfService = NSQualityOfServiceDefault; } [self.dataTask resume]; - NSArray *tokens = [self.callbackTokens copy]; + NSArray *tokens; + @synchronized (self) { + tokens = [self.callbackTokens copy]; + } for (SDWebImageDownloaderOperationToken *token in tokens) { if (token.progressBlock) { token.progressBlock(0, NSURLResponseUnknownLength, self.request.URL);