From 0e06f5457ca6df8d2c27ece50f462f28ac85c3ff Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 6 Jun 2025 01:27:54 -0700 Subject: [PATCH] Bug Fix: Add some safety checks to URL handlers A few places could have used nil checks, but there shouldn't be anything passing nil URLs to these. Well, just in case, at least it won't lead to crashes or something... Signed-off-by: Christopher Snowhill --- Audio/Chain/BufferChain.m | 6 +++++- Playlist/PlaylistLoader.m | 1 + Utils/SandboxBroker.m | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Audio/Chain/BufferChain.m b/Audio/Chain/BufferChain.m index c72c31608..bfed76bd6 100644 --- a/Audio/Chain/BufferChain.m +++ b/Audio/Chain/BufferChain.m @@ -52,10 +52,14 @@ } - (BOOL)open:(NSURL *)url withOutputFormat:(AudioStreamBasicDescription)outputFormat withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi { + if(!url) { + DLog(@"Player attempted to play invalid file..."); + return NO; + } [self setStreamURL:url]; [self setUserInfo:userInfo]; - if (![self buildChain]) { + if(![self buildChain]) { DLog(@"Couldn't build processing chain..."); return NO; } diff --git a/Playlist/PlaylistLoader.m b/Playlist/PlaylistLoader.m index 01d8e1f76..81f898a2d 100644 --- a/Playlist/PlaylistLoader.m +++ b/Playlist/PlaylistLoader.m @@ -1112,6 +1112,7 @@ NSURL *_Nullable urlForPath(NSString *_Nullable path); } - (NSArray *)addURL:(NSURL *)url { + if(!url) return [NSArray array]; return [self insertURLs:@[url] atIndex:(int)[[playlistController content] count] sort:NO]; } diff --git a/Utils/SandboxBroker.m b/Utils/SandboxBroker.m index 7683f2876..b3f1a3570 100644 --- a/Utils/SandboxBroker.m +++ b/Utils/SandboxBroker.m @@ -420,6 +420,7 @@ static inline void dispatch_async_reentrant(dispatch_queue_t queue, dispatch_blo } - (const void *)beginFolderAccess:(NSURL *)fileUrl { + if(!fileUrl) return NULL; NSURL *folderUrl = [SandboxBroker urlWithoutFragment:fileUrl]; if(![folderUrl isFileURL]) return NULL;