Fix string index out of bounds exception, credit to @void256 for finding

and reporting.
This commit is contained in:
kappaOne 2013-10-13 19:17:04 +01:00
parent d3254e00f3
commit eb85196a0c
1 changed files with 2 additions and 2 deletions

View File

@ -283,13 +283,13 @@ final class MacOSXNativeKeyboard extends EventQueue {
public void keyPressed(int key_code, String chars, long nanos) {
// use only first character of chars returned for key press
int character = (chars == null) ? 0 : (int)chars.charAt(0);
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
handleKey(key_code, (byte)1, character, nanos);
}
public void keyReleased(int key_code, String chars, long nanos) {
// use only first character of chars returned for key release
int character = (chars == null) ? 0 : (int)chars.charAt(0);
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
handleKey(key_code, (byte)0, character, nanos);
}