From 98f020f610181a18bd48d11361460cddbbb39160 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 5 Nov 2017 06:40:35 +0800 Subject: [PATCH] Fix WebP progressive decoding may do extra calculate because that libwebp will output last_y to zero, which means current image data is not enough to decode first stride --- SDWebImage/SDWebImageWebPCoder.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImageWebPCoder.m b/SDWebImage/SDWebImageWebPCoder.m index 7dbe1afa..48a1ff2b 100644 --- a/SDWebImage/SDWebImageWebPCoder.m +++ b/SDWebImage/SDWebImageWebPCoder.m @@ -166,7 +166,8 @@ int last_y = 0; int stride = 0; uint8_t *rgba = WebPIDecGetRGB(_idec, &last_y, &width, &height, &stride); - if (width + height > 0 && height >= last_y) { + // last_y may be 0, means no enough bitmap data to decode, ignore this + if (width + height > 0 && last_y > 0 && height >= last_y) { // Construct a UIImage from the decoded RGBA value array CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, rgba, 0, NULL);