mirror of https://github.com/mpv-player/mpv
{mac,cocoa}: trim trailing null out of macosx_icon when loading it
This prevents crashes when loading the application icon image. Suggested-by: Akemi <der.richter@gmx.de>
This commit is contained in:
parent
ada4f7c600
commit
1842a932d3
|
@ -127,8 +127,9 @@ static const char macosx_icon[] =
|
|||
|
||||
- (NSImage *)getMPVIcon
|
||||
{
|
||||
// The C string contains a trailing null, so we strip it away
|
||||
NSData *icon_data = [NSData dataWithBytesNoCopy:(void *)macosx_icon
|
||||
length:sizeof(macosx_icon)
|
||||
length:sizeof(macosx_icon) - 1
|
||||
freeWhenDone:NO];
|
||||
return [[NSImage alloc] initWithData:icon_data];
|
||||
}
|
||||
|
|
|
@ -172,8 +172,10 @@ static void set_application_icon(NSApplication *app)
|
|||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
if ([bundle pathForResource:@"icon" ofType:@"icns"])
|
||||
return;
|
||||
|
||||
// The C string contains a trailing null, so we strip it away
|
||||
NSData *icon_data = [NSData dataWithBytesNoCopy:(void *)macosx_icon
|
||||
length:sizeof(macosx_icon)
|
||||
length:sizeof(macosx_icon) - 1
|
||||
freeWhenDone:NO];
|
||||
NSImage *icon = [[NSImage alloc] initWithData:icon_data];
|
||||
[app setApplicationIconImage:icon];
|
||||
|
|
Loading…
Reference in New Issue