From d7d6014789ab43f6c0be9ae4d97b247bba500c1f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 29 Nov 2022 00:49:27 -0800 Subject: [PATCH] Sandbox Broker: Fixed a potential reference crash The code which looked up Sandbox handles for a given path had a bug where it would re-add the handle to the in-memory cache storage even if it already had just retrieved the current handle from the cache. I hope this will fix the crashes which have been plaguing people adding a lot of files to the playlist all at once from a single folder. Signed-off-by: Christopher Snowhill --- Utils/SandboxBroker.m | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index a828c6d0e..5ddb0f92f 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -435,16 +435,12 @@ static inline void dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_bloc if(!_entry) { _entry = [self recursivePathTest:folderUrl]; + if(_entry) + [self->storage addObject:_entry]; } - if(_entry) { - [self->storage addObject:_entry]; - - if(_entry.secureUrl) { - [_entry.secureUrl startAccessingSecurityScopedResource]; - } - } else { - _entry = NULL; + if(_entry && _entry.secureUrl) { + [_entry.secureUrl startAccessingSecurityScopedResource]; } });