mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-19 02:36:27 +01:00
InputConfigDiag: Fix a segfault caused by missing check
The original code assumed that we would always find a button in control_buttons. However, this is incorrect, since the iterator can and will be control_buttons.end() if the button that triggered the iterate code is not in control_buttons, which happens when it's in an exclude list.
This commit is contained in:
parent
0bd5db3e05
commit
b59e919919
@ -523,12 +523,14 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
|
|||||||
|
|
||||||
void GamepadPage::DetectControl(wxCommandEvent& event)
|
void GamepadPage::DetectControl(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
ControlButton* btn = (ControlButton*)event.GetEventObject();
|
auto* btn = static_cast<ControlButton*>(event.GetEventObject());
|
||||||
if (DetectButton(btn) && m_iterate == true)
|
if (DetectButton(btn) && m_iterate)
|
||||||
{
|
{
|
||||||
auto it = std::find(control_buttons.begin(), control_buttons.end(), btn);
|
auto it = std::find(control_buttons.begin(), control_buttons.end(), btn);
|
||||||
|
// it can and will be control_buttons.end() for any control that is in the exclude list.
|
||||||
|
if (it == control_buttons.end())
|
||||||
|
return;
|
||||||
|
|
||||||
// std find will never return end since btn will always be found in control_buttons
|
|
||||||
++it;
|
++it;
|
||||||
for (; it != control_buttons.end(); ++it)
|
for (; it != control_buttons.end(); ++it)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user