pcsx2: prevent a potential null deference

CID 146889 (#1 of 1): Dereference null return value (NULL_RETURNS)4. dereference: Dereferencing a pointer that might be null wxGetApp()->GetDisassemblyPtr() when calling update

FindWindowById returns NULL if the Window with the given id is not found, no need to do a extra check for validation of the id. also do a check for wxGetApp()->GetDisassemblyPtr() to prevent a null deference.
This commit is contained in:
Akash 2015-10-14 20:11:06 +05:30
parent 04b765a674
commit b8caab5f3d
2 changed files with 4 additions and 3 deletions

View File

@ -392,6 +392,7 @@ void CBreakPoints::Update(u32 addr)
if (resume)
r5900Debug.resumeCpu();
wxGetApp().GetDisassemblyPtr()->update();
auto disassembly_window = wxGetApp().GetDisassemblyPtr();
if (disassembly_window) // make sure that valid pointer is recieved to prevent potential NULL dereference.
disassembly_window->update();
}

View File

@ -514,7 +514,7 @@ public:
GSFrame* GetGsFramePtr() const { return (GSFrame*)wxWindow::FindWindowById( m_id_GsFrame ); }
MainEmuFrame* GetMainFramePtr() const { return (MainEmuFrame*)wxWindow::FindWindowById( m_id_MainFrame ); }
DisassemblyDialog* GetDisassemblyPtr() const { return m_id_Disassembler ? (DisassemblyDialog*)wxWindow::FindWindowById( m_id_Disassembler ) : NULL; }
DisassemblyDialog* GetDisassemblyPtr() const { return (DisassemblyDialog*)wxWindow::FindWindowById(m_id_Disassembler); }
void enterDebugMode();
void leaveDebugMode();