summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2021-12-13 19:04:07 -0500
committerGravatar Morph2021-12-13 19:04:07 -0500
commit96579e515a8da3eb6c1aab13a4d4ff5d9577605a (patch)
tree3cdf3667d1bb19d438eff633dee02b59ad5a8391
parentMerge pull request #7574 from v1993/patch-1 (diff)
downloadyuzu-96579e515a8da3eb6c1aab13a4d4ff5d9577605a.tar.gz
yuzu-96579e515a8da3eb6c1aab13a4d4ff5d9577605a.tar.xz
yuzu-96579e515a8da3eb6c1aab13a4d4ff5d9577605a.zip
qt_software_keyboard: Fix out of bounds array access
We were unconditionally accessing the keyboard_buttons array, even if the bottom_osk_index was for the numberpad, leading to an out of bounds array access. Fix this by accessing the proper array for the current button when the index is for the numberpad.
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index de7f98c4f..c3857fc98 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -475,11 +475,26 @@ void QtSoftwareKeyboardDialog::open() {
475 row = 0; 475 row = 0;
476 column = 0; 476 column = 0;
477 477
478 const auto* const curr_button = 478 switch (bottom_osk_index) {
479 keyboard_buttons[static_cast<int>(bottom_osk_index)][row][column]; 479 case BottomOSKIndex::LowerCase:
480 case BottomOSKIndex::UpperCase: {
481 const auto* const curr_button =
482 keyboard_buttons[static_cast<std::size_t>(bottom_osk_index)][row][column];
483
484 // This is a workaround for setFocus() randomly not showing focus in the UI
485 QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center()));
486 break;
487 }
488 case BottomOSKIndex::NumberPad: {
489 const auto* const curr_button = numberpad_buttons[row][column];
480 490
481 // This is a workaround for setFocus() randomly not showing focus in the UI 491 // This is a workaround for setFocus() randomly not showing focus in the UI
482 QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center())); 492 QCursor::setPos(curr_button->mapToGlobal(curr_button->rect().center()));
493 break;
494 }
495 default:
496 break;
497 }
483 498
484 StartInputThread(); 499 StartInputThread();
485} 500}