You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in SDWebImageDownloaderOperation.m there is a mistake which will result in a crash when connection:didReceiveResponse: handles a NSURLResponse (ie, a link to a local file in cache) rather than a NSHTTPURLResponse.
The issue is a simple commutative mistake with a simple fix.
The offending delegate method:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
//'304 Not Modified' is an exceptional oneif ((![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400) && [((NSHTTPURLResponse *)response) statusCode] != 304) {
NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0;
self.expectedSize = expected;
if (self.progressBlock) {
self.progressBlock(0, expected);
}
self.imageData = [[NSMutableDataalloc] initWithCapacity:expected];
self.response = response;
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenterdefaultCenter] postNotificationName:SDWebImageDownloadReceiveResponseNotification object:self];
});
}
else {
NSUInteger code = [((NSHTTPURLResponse *)response) statusCode];
//This is the case when server returns '304 Not Modified'. It means that remote image is not changed.//In case of 304 we need just cancel the operation and return cached image from the cache.if (code == 304) {
[selfcancelInternal];
} else {
[self.connection cancel];
}
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenterdefaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self];
});
if (self.completedBlock) {
self.completedBlock(nil, nil, [NSErrorerrorWithDomain:NSURLErrorDomaincode:[((NSHTTPURLResponse *)response) statusCode] userInfo:nil], YES);
}
CFRunLoopStop(CFRunLoopGetCurrent());
[selfdone];
}
}
in SDWebImageDownloaderOperation.m there is a mistake which will result in a crash when
connection:didReceiveResponse:
handles a NSURLResponse (ie, a link to a local file in cache) rather than a NSHTTPURLResponse.The issue is a simple commutative mistake with a simple fix.
The offending delegate method:
The offending line alone:
The proposed fix:
The text was updated successfully, but these errors were encountered: