mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
{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:
committed by
Jan Ekström
parent
ada4f7c600
commit
1842a932d3
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user