Compare commits

...

2 commits

Author SHA1 Message Date
Christopher Snowhill
0e06f5457c Bug Fix: Add some safety checks to URL handlers
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled
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 <kode54@gmail.com>
2025-06-06 01:27:54 -07:00
Christopher Snowhill
1d847eb96c Bug Fix: Really old legacy code error crash fix
This legacy playlist filename handler was falling through on newly
installed and run setups, where none of the files would exist, so the
last one would return a nil NSURL and attempt to add it to the playlist.

Fix this to check for the existence of the file before attempting to
open it. It shouldn't really exist anyway, unless someone really started
with a really old version somehow, and migrated it to the sandbox folder
proper.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
2025-06-06 01:26:06 -07:00
4 changed files with 15 additions and 2 deletions

View file

@ -210,8 +210,15 @@ static BOOL consentLastEnabled = NO;
[playlistLoader addDatabase];
} else if([[NSFileManager defaultManager] fileExistsAtPath:[basePath stringByAppendingPathComponent:newFilename]]) {
[playlistLoader addURL:[NSURL fileURLWithPath:[basePath stringByAppendingPathComponent:newFilename]]];
} else {
} else if([[NSFileManager defaultManager] fileExistsAtPath:[basePath stringByAppendingPathComponent:oldFilename]]){
/* Without the above check, it appears the code was retrieving a nil NSURL from the nonexistent path
* Then adding it to the playlist and crashing further down the line
* Nobody on a new setup should be seeing this open anything, so it should fall through to the
* notice below.
*/
[playlistLoader addURL:[NSURL fileURLWithPath:[basePath stringByAppendingPathComponent:oldFilename]]];
} else {
ALog(@"No playlist found, leaving it empty.");
}
}

View file

@ -52,6 +52,10 @@
}
- (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];

View file

@ -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];
}

View file

@ -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;