[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
Christopher Snowhill 2022-06-09 23:18:51 -07:00
parent 2dabcb2581
commit e96a4efa68
2 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,8 @@ static void cache_deinit() {
}
static void cache_insert_properties(NSURL *url, NSDictionary *properties) {
if(properties == nil) return;
std::lock_guard<std::mutex> lock(Cache_Lock);
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) {
if(metadata == nil) return;
std::lock_guard<std::mutex> lock(Cache_Lock);
std::string path = [[url absoluteString] UTF8String];

View File

@ -52,6 +52,8 @@
}
- (NSDictionary *)coalesceEntryInfo:(NSDictionary *)entryInfo {
if(entryInfo == nil) return entryInfo;
__block NSMutableDictionary *ret = [[NSMutableDictionary alloc] initWithCapacity:[entryInfo count]];
[entryInfo enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) {