From 32f4a7594a2fbfd3c0fbd50a856b1fd0f10c7bde Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Nov 2013 23:53:18 -0800 Subject: [PATCH] Add bounds checks to columns accessors. Hit a crash in one of these on a rare case, so better to check. --- Windows/Debugger/Debugger_Lists.cpp | 8 ++++++++ Windows/GEDebugger/TabDisplayLists.cpp | 6 ++++++ Windows/GEDebugger/TabState.cpp | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 5e7a4a8826..cd7cd5b5e7 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -129,6 +129,10 @@ void CtrlThreadList::showMenu(int itemIndex, const POINT &pt) void CtrlThreadList::GetColumnText(wchar_t* dest, int row, int col) { + if (row < 0 || row >= (int)threads.size()) { + return; + } + switch (col) { case TL_NAME: @@ -618,6 +622,10 @@ bool CtrlStackTraceView::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, L void CtrlStackTraceView::GetColumnText(wchar_t* dest, int row, int col) { + if (row < 0 || row >= (int)frames.size()) { + return; + } + switch (col) { case SF_ENTRY: diff --git a/Windows/GEDebugger/TabDisplayLists.cpp b/Windows/GEDebugger/TabDisplayLists.cpp index a228b548f5..6ad1b1fdc7 100644 --- a/Windows/GEDebugger/TabDisplayLists.cpp +++ b/Windows/GEDebugger/TabDisplayLists.cpp @@ -33,6 +33,9 @@ CtrlDisplayListStack::CtrlDisplayListStack(HWND hwnd): GenericListControl(hwnd,d void CtrlDisplayListStack::GetColumnText(wchar_t* dest, int row, int col) { + if (row < 0 || row >= (int)ARRAY_SIZE(list.stack)) { + return; + } DisplayListStackEntry value = list.stack[row]; switch (col) @@ -77,6 +80,9 @@ CtrlAllDisplayLists::CtrlAllDisplayLists(HWND hwnd): GenericListControl(hwnd,all void CtrlAllDisplayLists::GetColumnText(wchar_t* dest, int row, int col) { + if (row < 0 || row >= (int)lists.size()) { + return; + } DisplayList& list = lists[row]; switch (col) diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 51bf7bb5f2..24f1ffd03a 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -633,6 +633,10 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab } void CtrlStateValues::GetColumnText(wchar_t *dest, int row, int col) { + if (row < 0 || row >= rowCount_) { + return; + } + switch (col) { case STATEVALUES_COL_NAME: wcscpy(dest, rows_[row].title);