Merge pull request #11379 from jdgleaver/keyboard-mapping-fix

Prevent out of bounds array acces when using left/right to remap 'Keyboard' device type inputs
This commit is contained in:
Autechre 2020-09-25 17:09:50 +02:00 committed by GitHub
commit eab0098216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -183,7 +183,7 @@ static int action_left_input_desc_kbd(unsigned type, const char *label,
remap_id =
settings->uints.input_keymapper_ids[user_idx][btn_idx];
for (key_id = 0; key_id < RARCH_MAX_KEYS - 1; key_id++)
for (key_id = 0; key_id < RARCH_MAX_KEYS; key_id++)
{
if (remap_id == key_descriptors[key_id].key)
break;
@ -192,7 +192,7 @@ static int action_left_input_desc_kbd(unsigned type, const char *label,
if (key_id > 0)
key_id--;
else
key_id = (RARCH_MAX_KEYS - 1) + MENU_SETTINGS_INPUT_DESC_KBD_BEGIN;
key_id = RARCH_MAX_KEYS - 1;
settings->uints.input_keymapper_ids[user_idx][btn_idx] = key_descriptors[key_id].key;

View File

@ -154,13 +154,13 @@ static int action_right_input_desc_kbd(unsigned type, const char *label,
remap_id =
settings->uints.input_keymapper_ids[user_idx][btn_idx];
for (key_id = 0; key_id < RARCH_MAX_KEYS - 1; key_id++)
for (key_id = 0; key_id < RARCH_MAX_KEYS; key_id++)
{
if (remap_id == key_descriptors[key_id].key)
break;
}
if (key_id < (RARCH_MAX_KEYS - 1) + MENU_SETTINGS_INPUT_DESC_KBD_BEGIN)
if (key_id < (RARCH_MAX_KEYS - 1))
key_id++;
else
key_id = 0;