Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cb62fe8 authored by Rishi Sikka's avatar Rishi Sikka
Browse files

inputflinger: Check for KeyCharacterMap before use

Fixes crash in InputReader:

10-09 23:27:30.342 F DEBUG   : pid: 2243, tid: 2413, name: InputReader  >>> system_server <<<
10-09 23:27:30.342 F DEBUG   : uid: 1000
10-09 23:27:30.342 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
10-09 23:27:30.342 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000040
10-09 23:27:30.342 F DEBUG   : Cause: null pointer dereference

Bug: 372558955
Test: Does not crash on input device without character map
Flag: EXEMPT bugfix
Change-Id: I0f4ada4663bdd51a233fa9c15eb2558db0081dd5
parent 5d649dcb
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -662,8 +662,12 @@ bool EventHub::Device::hasKeycodeLocked(int keycode) const {
    if (hasKeycodeInternalLocked(keycode)) {
        return true;
    }

    for (auto& fromKey : getKeyCharacterMap()->findKeyCodesMappedToKeyCode(keycode)) {
    // Check the key character map first. Not all input devices will have one.
    const std::shared_ptr<KeyCharacterMap> kcm = getKeyCharacterMap();
    if (kcm == nullptr) {
        return false;
    }
    for (auto& fromKey : kcm->findKeyCodesMappedToKeyCode(keycode)) {
        if (hasKeycodeInternalLocked(fromKey)) {
            return true;
        }