Fix the missing lock for callbackTokens which may cause thread-safe issue

This commit is contained in:
DreamPiggy 2022-11-11 14:22:49 +08:00
parent bc3f09ccbd
commit 384b2d7c8b
1 changed files with 4 additions and 1 deletions

View File

@ -244,7 +244,10 @@
self.coderQueue.qualityOfService = NSQualityOfServiceDefault; self.coderQueue.qualityOfService = NSQualityOfServiceDefault;
} }
[self.dataTask resume]; [self.dataTask resume];
NSArray<SDWebImageDownloaderOperationToken *> *tokens = [self.callbackTokens copy]; NSArray<SDWebImageDownloaderOperationToken *> *tokens;
@synchronized (self) {
tokens = [self.callbackTokens copy];
}
for (SDWebImageDownloaderOperationToken *token in tokens) { for (SDWebImageDownloaderOperationToken *token in tokens) {
if (token.progressBlock) { if (token.progressBlock) {
token.progressBlock(0, NSURLResponseUnknownLength, self.request.URL); token.progressBlock(0, NSURLResponseUnknownLength, self.request.URL);