Fix crash when pressing Tab

When pressing Tab for a long time, Dolphin will sooner or later crash
because the result of FindFocus() has become NULL (toctou).
This commit is contained in:
Tillmann Karras 2014-02-22 21:08:20 +01:00
parent 4f3227b4a9
commit 296637d6f2
1 changed files with 7 additions and 4 deletions

View File

@ -706,13 +706,16 @@ bool CFrame::RendererHasFocus()
if (m_RenderParent->GetParent()->GetHWND() == GetForegroundWindow())
return true;
#else
if (wxWindow::FindFocus() == nullptr)
wxWindow *window = wxWindow::FindFocus();
if (window == nullptr)
return false;
// Why these different cases?
if (m_RenderParent == wxWindow::FindFocus() ||
m_RenderParent == wxWindow::FindFocus()->GetParent() ||
m_RenderParent->GetParent() == wxWindow::FindFocus()->GetParent())
if (m_RenderParent == window ||
m_RenderParent == window->GetParent() ||
m_RenderParent->GetParent() == window->GetParent())
{
return true;
}
#endif
return false;
}