[Metadata Loading] Added null pointer guards
This prevents crashes where inputs were not returning either properties or metadata blocks and the file open cache was attempting to cache the resulting nil pointer as if it were valid. Also prevent the metadata redundant string coalescing from processing nil objects as well, in case it's used that way somewhere else. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
2dabcb2581
commit
e96a4efa68
|
@ -49,6 +49,8 @@ static void cache_deinit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cache_insert_properties(NSURL *url, NSDictionary *properties) {
|
static void cache_insert_properties(NSURL *url, NSDictionary *properties) {
|
||||||
|
if(properties == nil) return;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(Cache_Lock);
|
std::lock_guard<std::mutex> lock(Cache_Lock);
|
||||||
|
|
||||||
std::string path = [[url absoluteString] UTF8String];
|
std::string path = [[url absoluteString] UTF8String];
|
||||||
|
@ -61,6 +63,8 @@ static void cache_insert_properties(NSURL *url, NSDictionary *properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cache_insert_metadata(NSURL *url, NSDictionary *metadata) {
|
static void cache_insert_metadata(NSURL *url, NSDictionary *metadata) {
|
||||||
|
if(metadata == nil) return;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(Cache_Lock);
|
std::lock_guard<std::mutex> lock(Cache_Lock);
|
||||||
|
|
||||||
std::string path = [[url absoluteString] UTF8String];
|
std::string path = [[url absoluteString] UTF8String];
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *)coalesceEntryInfo:(NSDictionary *)entryInfo {
|
- (NSDictionary *)coalesceEntryInfo:(NSDictionary *)entryInfo {
|
||||||
|
if(entryInfo == nil) return entryInfo;
|
||||||
|
|
||||||
__block NSMutableDictionary *ret = [[NSMutableDictionary alloc] initWithCapacity:[entryInfo count]];
|
__block NSMutableDictionary *ret = [[NSMutableDictionary alloc] initWithCapacity:[entryInfo count]];
|
||||||
|
|
||||||
[entryInfo enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) {
|
[entryInfo enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) {
|
||||||
|
|
Loading…
Reference in New Issue