From 7e96b776ca62aada629650b0db98fb36117779bb Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Sun, 28 Jan 2018 19:06:46 +0800 Subject: [PATCH] Fix the issue that prefetcher will cause stack overflow is the input urls list is huge because of recursion function call --- SDWebImage/SDWebImagePrefetcher.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDWebImage/SDWebImagePrefetcher.m b/SDWebImage/SDWebImagePrefetcher.m index cabf132d..18c433e7 100644 --- a/SDWebImage/SDWebImagePrefetcher.m +++ b/SDWebImage/SDWebImagePrefetcher.m @@ -80,7 +80,8 @@ ]; } if (self.prefetchURLs.count > self.requestedCount) { - dispatch_queue_async_safe(self.prefetcherQueue, ^{ + dispatch_async(self.prefetcherQueue, ^{ + // we need dispatch to avoid function recursion call. This can prevent stack overflow even for huge urls list [self startPrefetchingAtIndex:self.requestedCount]; }); } else if (self.finishedCount == self.requestedCount) {