summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-25 17:58:34 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-12-25 18:13:09 +0100
commita410a750c74c49e004ddd442e0debda891d83126 (patch)
treee2cf801689ff50d188938e80f48848e5734deb81 /video
parent7d553a4c26e3add66d636bcde6b74fb48cfceabf (diff)
downloadmpv-a410a750c74c49e004ddd442e0debda891d83126.tar.bz2
mpv-a410a750c74c49e004ddd442e0debda891d83126.tar.xz
cocoa: sanitize window title string and guard against NULL
If the utf8 string used to create the NSString for title was invalid utf8, -stringWithUTF8String returned nil and triggered an assertion in Cocoa's framework code. Sanitize the utf8 string and if the sanitation wasn't enough just avoid crashing by not setting a title. Fixes #406
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa_common.m7
1 files changed, 6 insertions, 1 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 29c06044fe..67436577cf 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -349,7 +349,12 @@ static int create_gl_context(struct vo *vo, int gl3profile)
static void cocoa_set_window_title(struct vo *vo, const char *title)
{
struct vo_cocoa_state *s = vo->cocoa;
- [s->window setTitle: [NSString stringWithUTF8String:title]];
+ void *talloc_ctx = talloc_new(NULL);
+ struct bstr btitle = bstr_sanitize_utf8_latin1(talloc_ctx, bstr0(title));
+ NSString *nstitle = [NSString stringWithUTF8String:btitle.start];
+ if (nstitle)
+ [s->window setTitle: nstitle];
+ talloc_free(talloc_ctx);
}
static void update_window(struct vo *vo, int d_width, int d_height)