Authored by Reid Main

Fixed bug where NSInvalidArgumentException was thrown if an image with a nil URL was downloaded.

... ... @@ -144,6 +144,17 @@ static NSString *const kCompletedCallbackKey = @"completed";
- (void)addProgressCallback:(void (^)(NSUInteger, long long))progressBlock andCompletedBlock:(void (^)(UIImage *, NSData *data, NSError *, BOOL))completedBlock forURL:(NSURL *)url createCallback:(void (^)())createCallback
{
// The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data and an error.
if(url == nil)
{
if (completedBlock != nil)
{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Could not load an image because URL was nil."}];
completedBlock(nil, nil, error, NO);
}
return;
}
dispatch_barrier_sync(self.barrierQueue, ^
{
BOOL first = NO;
... ...