Mac crash on dead key keydown: When typing "~" in the search field on mac osx with i18n keyboard
On Mac OS X 10.8, with my keyboard set to Norwegian, trying to type "" in the search field in the main window crashes the app. On this keyboard layout, "" is produced by holding Ctrl and then pressing the "¨" key.
It looks like the problem is that the keydown event produces an event where "charactersIgnoringModifiers" returns an empty (0-length) string. The following code does not verify the length before trying to access the first character:
and so VLC crashes with an NSRangeException.
Application Specific Information:
Crashing on exception: -[__NSCFString characterAtIndex:]: Range or index out of bounds
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8c20e716 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8c9f5470 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c20e4ec +[NSException raise:format:] + 204
3 CoreFoundation 0x00007fff8c1d2ffe -[__NSCFString characterAtIndex:] + 94
4 libmacosx_plugin.dylib 0x00000001055b74d0 -[VLCMain hasDefinedShortcutKey:force:] + 208
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x00007fff8b896911 -[NSApplication _crashOnException:] + 106
1 com.apple.AppKit 0x00007fff8b896c12 -[NSApplication _showException:] + 690
2 com.apple.AppKit 0x00007fff8b63fd42 -[NSApplication run] + 836
3 libmacosx_plugin.dylib 0x00000001055b39ae Run + 206
4 libvlccore.5.dylib 0x0000000100039932 intf_Create + 770
5 libvlccore.5.dylib 0x000000010002bb47 libvlc_InternalAddIntf + 215
6 libvlc.5.dylib 0x000000010000814f libvlc_add_intf + 15
7 org.videolan.vlc 0x0000000100002a97 main + 455
8 org.videolan.vlc 0x00000001000028a4 start + 52
Trying to run "/Applications/VLC.app/Contents/MacOS/VLC -- -NSTraceEvents YES" shows:
2012-08-03 09:55:49.932 VLC[6539:707] Received event: KeyDown at: 714.0,184.0 time: 14659180603000 flags: 0x40101 win: 0 ctxt: 1e297 data: 0,252,126,30,168
2012-08-03 09:55:49.933 VLC[6539:707] In Application: NSEvent: type=KeyDown loc=(0,490) time=14659.2 flags=0x40101 win=0x0 winNum=1001 ctxt=0x0 chars="~" unmodchars="" repeat=0 keyCode=30
2012-08-03 09:55:49.933 VLC[6539:707] -[__NSCFString characterAtIndex:]: Range or index out of bounds
2012-08-03 09:55:49.937 VLC[6539:707] (
0 CoreFoundation 0x00007fff8c20e716 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8c9f5470 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c20e4ec +[NSException raise:format:] + 204
3 CoreFoundation 0x00007fff8c1d2ffe -[__NSCFString characterAtIndex:] + 94
4 libmacosx_plugin.dylib 0x000000010572c4d0 -[VLCMain hasDefinedShortcutKey:force:] + 208
)