From 1842a932d37638c910f4471d85e81554076c3d2c Mon Sep 17 00:00:00 2001 From: Rodger Combs Date: Sun, 1 Jul 2018 04:56:08 -0500 Subject: {mac,cocoa}: trim trailing null out of macosx_icon when loading it This prevents crashes when loading the application icon image. Suggested-by: Akemi --- osdep/macosx_application.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'osdep') diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index ca613e04f4..086d51fef3 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -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]; } -- cgit v1.2.3