From 616d824dc7b5614c61e4b4a9f10dc35d2d333931 Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Mon, 10 Dec 2012 15:25:45 +0100 Subject: [PATCH] Return an error if the downloaded image has no pixels (fix #241) --- SDWebImage/SDWebImageDownloaderOperation.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index d2f37327..5ebb9252 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -274,7 +274,14 @@ UIImage *image = [UIImage decodedImageWithImage:SDScaledImageForPath(self.request.URL.absoluteString, self.imageData)]; dispatch_async(dispatch_get_main_queue(), ^ { - completionBlock(image, self.imageData, nil, YES); + if (CGSizeEqualToSize(image.size, CGSizeZero)) + { + completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Downloaded image has 0 pixels"}], YES); + } + else + { + completionBlock(image, self.imageData, nil, YES); + } self.completionBlock = nil; [self done]; });