Terminal: Fix crash for keystroke with unexpected modifiers
This patch fixes a segfault in Terminal that happens when you issue a keystroke with unexpected modifiers. An easy way to repro this is: 1. Set command key to super 2. Set option key to meta in Terminal 3. Issue `ctrl+alt+shift+<key>` In DefaultState::KeyDown(), the branch that handles option key as meta detects that additional modifiers were used along with the meta key and tries to look up the keymap associated with that combination of modifier keys. This lookup in TermView::fKeymapTableForModifierse can return NULL, since TermView::SetKeymap() sets a pre-defined set of (modifier combo) => keymap entries. Change-Id: I3ce4a7cff6c84913d99507e44849f9b048769f67 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2138 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
e8b9c0e1a6
commit
8d763b7f0d
@@ -218,12 +218,13 @@ TermView::DefaultState::KeyDown(const char* bytes, int32 numBytes)
|
||||
// Determine the character produced by the same keypress without the
|
||||
// Option key
|
||||
mod &= B_SHIFT_KEY | B_CAPS_LOCK | B_CONTROL_KEY;
|
||||
if (mod == 0) {
|
||||
const int32 (*keymapTable)[128] = (mod == 0)
|
||||
? NULL
|
||||
: fView->fKeymapTableForModifiers.Get(mod);
|
||||
if (keymapTable == NULL) {
|
||||
bytes = (const char*)&rawChar;
|
||||
numBytes = 1;
|
||||
} else {
|
||||
const int32 (*keymapTable)[128] =
|
||||
fView->fKeymapTableForModifiers.Get(mod);
|
||||
bytes = &fView->fKeymapChars[(*keymapTable)[key]];
|
||||
numBytes = *(bytes++);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user