Skip to content

Commit

Permalink
macosx: fix possible SPMediaKeyTap crash
Browse files Browse the repository at this point in the history
Adding nil to an NSArray would make it raise an
NSInvalidArgumentException which in turn leads to an abort in
dispatch_once:
  https://github.com/apple-oss-distributions/libdispatch/blob/55c3a68e9ec47f1c1d5bb9909404ce5f0351edef/src/object.m#L557

Fix #27487
  • Loading branch information
ePirat authored and fkuehne committed Nov 8, 2022
1 parent 031bb0f commit 41ec80a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/gui/macosx/imported/SPMediaKeyTap/SPMediaKeyTap.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,13 @@ + (NSArray*)mediaKeyUserBundleIdentifiers
static NSArray *bundleIdentifiers;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *ourIdentifier = [[NSBundle mainBundle] bundleIdentifier];
if (ourIdentifier == nil) {
NSLog(@"SPMediaKeyTap: Bundle identifier unexpectedly nil, falling back to org.videolan.vlc");
ourIdentifier = @"org.videolan.vlc";
}
bundleIdentifiers = @[
[[NSBundle mainBundle] bundleIdentifier], // your app
ourIdentifier, // your app
@"com.spotify.client",
@"com.apple.iTunes",
@"com.apple.Music",
Expand Down

0 comments on commit 41ec80a

Please sign in to comment.