8178274: Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyInfo() overreads jchar variable
Reviewed-by: ssadetsky
This commit is contained in:
parent
1b2b0e8cb9
commit
0b924bfad1
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -387,7 +387,7 @@ unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers, BOOL spaceKeyType
|
||||
if (nsChar == 0 && spaceKeyTyped == YES) {
|
||||
return java_awt_event_KeyEvent_VK_SPACE;
|
||||
}
|
||||
|
||||
|
||||
// otherwise return character unchanged
|
||||
return nsChar;
|
||||
}
|
||||
@ -439,7 +439,8 @@ static unichar NsGetDeadKeyChar(unsigned short keyCode)
|
||||
static void
|
||||
NsCharToJavaVirtualKeyCode(unichar ch, BOOL isDeadChar,
|
||||
NSUInteger flags, unsigned short key,
|
||||
jint *keyCode, jint *keyLocation, BOOL *postsTyped, unichar *deadChar)
|
||||
jint *keyCode, jint *keyLocation, BOOL *postsTyped,
|
||||
unichar *deadChar)
|
||||
{
|
||||
static size_t size = sizeof(keyTable) / sizeof(struct _key);
|
||||
NSInteger offset;
|
||||
@ -562,10 +563,10 @@ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods)
|
||||
{
|
||||
jint javaModifiers = 0;
|
||||
const struct _nsKeyToJavaModifier* cur;
|
||||
|
||||
|
||||
for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
|
||||
if ((cur->nsMask & nsFlags) != 0) {
|
||||
|
||||
|
||||
if (cur->nsMask == NSAlternateKeyMask) {
|
||||
if (leftAltKeyPressed == YES) {
|
||||
javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask;
|
||||
@ -707,16 +708,17 @@ JNF_COCOA_ENTER(env);
|
||||
|
||||
jint jkeyCode = java_awt_event_KeyEvent_VK_UNDEFINED;
|
||||
jint jkeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
|
||||
jchar testDeadChar = 0;
|
||||
jint testDeadChar = 0;
|
||||
|
||||
NsCharToJavaVirtualKeyCode((unichar)testChar, isDeadChar,
|
||||
(NSUInteger)modifierFlags, (unsigned short)keyCode,
|
||||
&jkeyCode, &jkeyLocation, &postsTyped, &testDeadChar);
|
||||
&jkeyCode, &jkeyLocation, &postsTyped,
|
||||
(unichar *) &testDeadChar);
|
||||
|
||||
// out = [jkeyCode, jkeyLocation];
|
||||
// out = [jkeyCode, jkeyLocation, deadChar];
|
||||
(*env)->SetIntArrayRegion(env, outData, 0, 1, &jkeyCode);
|
||||
(*env)->SetIntArrayRegion(env, outData, 1, 1, &jkeyLocation);
|
||||
(*env)->SetIntArrayRegion(env, outData, 2, 1, (jint *)&testDeadChar);
|
||||
(*env)->SetIntArrayRegion(env, outData, 2, 1, &testDeadChar);
|
||||
|
||||
(*env)->ReleaseIntArrayElements(env, inData, data, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user