aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar Rodger Combs <rodger.combs@gmail.com>2018-07-01 04:56:08 -0500
committerGravatar Jan Ekström <jeebjp@gmail.com>2018-10-02 00:20:43 +0300
commit1842a932d37638c910f4471d85e81554076c3d2c (patch)
treec536f9ab1b352530dce85e7cb38c4f1a8407db7d /video
parentada4f7c6006fc60189987b3ee012e7f4ced9926e (diff)
{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>
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa_common.m4
1 files changed, 3 insertions, 1 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index abead0fb53..b4283bbe8d 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -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];