Merge pull request #3740 from zkforever/fixCrash
Fix the crash when some special urls cause the cache path return nil and crash
This commit is contained in:
commit
99acb03c96
|
@ -64,6 +64,11 @@ static NSString * const SDDiskCacheExtendedAttributeName = @"com.hackemist.SDDis
|
||||||
- (NSData *)dataForKey:(NSString *)key {
|
- (NSData *)dataForKey:(NSString *)key {
|
||||||
NSParameterAssert(key);
|
NSParameterAssert(key);
|
||||||
NSString *filePath = [self cachePathForKey:key];
|
NSString *filePath = [self cachePathForKey:key];
|
||||||
|
// if filePath is nil or (null),framework will crash with this:
|
||||||
|
// Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[_NSPlaceholderData initWithContentsOfFile:options:maxLength:error:]: nil file argument'
|
||||||
|
if (filePath == nil || [@"(null)" isEqualToString: filePath]) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
NSData *data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil];
|
NSData *data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil];
|
||||||
if (data) {
|
if (data) {
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in New Issue