From ee6ad403a7c73e587c6de7ced71861df29413926 Mon Sep 17 00:00:00 2001 From: der richter Date: Sat, 22 Feb 2020 14:21:06 +0100 Subject: cocoa-cb: fix crash with some japanese characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the actual character that made mpv crash is IDEOGRAPHIC COMMA (U+3001, UTF-8: E3 80 81, 、) and that only in some specific circumstances that could be reliably reproduced on my end. using an NSString instead of the Swift String actually fixes that issues even though they should technically do the exact same thing. i tested all the other String initialisers, but they all had had the same issue. this is kinda only a workaround till i can find a different way of handling it. --- video/out/cocoa_cb_common.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'video') diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift index 493932ff7f..7fc4d0c0ea 100644 --- a/video/out/cocoa_cb_common.swift +++ b/video/out/cocoa_cb_common.swift @@ -539,7 +539,8 @@ class CocoaCB: NSObject { case VOCTRL_UPDATE_WINDOW_TITLE: if let titleData = data?.assumingMemoryBound(to: Int8.self) { DispatchQueue.main.async { - ccb.title = String(cString: titleData) + let title = NSString(utf8String: titleData) as String? + ccb.title = title ?? "Unknown Title" } return VO_TRUE } -- cgit v1.2.3