Add extra check for image data during URLSession data callback

Make sure the assert work
This commit is contained in:
DreamPiggy 2023-08-23 17:54:14 +08:00
parent c614dffdfd
commit 1550747f2a
1 changed files with 1 additions and 2 deletions

View File

@ -553,7 +553,7 @@ didReceiveResponse:(NSURLResponse *)response
NSData *imageData = self.imageData; NSData *imageData = self.imageData;
// keep maximum one progressive decode process during download // keep maximum one progressive decode process during download
if (self.coderQueue.operationCount == 0) { if (imageData && self.coderQueue.operationCount == 0) {
// NSOperation have autoreleasepool, don't need to create extra one // NSOperation have autoreleasepool, don't need to create extra one
@weakify(self); @weakify(self);
[self.coderQueue addOperationWithBlock:^{ [self.coderQueue addOperationWithBlock:^{
@ -632,7 +632,6 @@ didReceiveResponse:(NSURLResponse *)response
} else { } else {
if (tokens.count > 0) { if (tokens.count > 0) {
NSData *imageData = self.imageData; NSData *imageData = self.imageData;
self.imageData = nil;
// data decryptor // data decryptor
if (imageData && self.decryptor) { if (imageData && self.decryptor) {
imageData = [self.decryptor decryptedDataWithData:imageData response:self.response]; imageData = [self.decryptor decryptedDataWithData:imageData response:self.response];