Merge pull request #4125 from leoetlino/fix-iterate-crash

InputConfigDiag: Fix a segfault caused by missing check
This commit is contained in:
Markus Wick 2016-08-22 16:58:14 +02:00 committed by GitHub
commit 8177eddd68
1 changed files with 5 additions and 3 deletions

View File

@ -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)
{ {