From 158ace470442066137cde9de7c96433786659f62 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 31 Oct 2011 22:33:24 +0000 Subject: [PATCH] debugger-fix mysterious out of bounds condition while editing breakpoints --- src/drivers/win/debugger.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/drivers/win/debugger.cpp b/src/drivers/win/debugger.cpp index 0023fb0b..0a889e62 100644 --- a/src/drivers/win/debugger.cpp +++ b/src/drivers/win/debugger.cpp @@ -656,11 +656,11 @@ void AddBreakList() { } void EditBreakList() { - if (WP_edit >= 0) { - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,WP_edit,0); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,WP_edit,(LPARAM)(LPSTR)BreakToText(WP_edit)); - SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_SETCURSEL,WP_edit,0); - } + if(WP_edit < 0) return; + if(WP_edit >= numWPs) return; + SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,WP_edit,0); + SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,WP_edit,(LPARAM)(LPSTR)BreakToText(WP_edit)); + SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_SETCURSEL,WP_edit,0); } void FillBreakList(HWND hwndDlg) { @@ -683,6 +683,8 @@ void ClearBreakList(HWND hwndDlg) { } void EnableBreak(int sel) { + if(sel<0) return; + if(sel>=numWPs) return; watchpoint[sel].flags^=WP_E; SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_DELETESTRING,sel,0); SendDlgItemMessage(hDebug,IDC_DEBUGGER_BP_LIST,LB_INSERTSTRING,sel,(LPARAM)(LPSTR)BreakToText(sel)); @@ -690,9 +692,10 @@ void EnableBreak(int sel) { } void DeleteBreak(int sel) { - int i; + if(sel<0) return; + if(sel>=numWPs) return; - for (i = sel; i < numWPs; i++) { + for (int i = sel; i < numWPs; i++) { watchpoint[i].address = watchpoint[i+1].address; watchpoint[i].endaddress = watchpoint[i+1].endaddress; watchpoint[i].flags = watchpoint[i+1].flags; @@ -1481,7 +1484,9 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara break; case LBN_DBLCLK: switch(LOWORD(wParam)) { - case IDC_DEBUGGER_BP_LIST: EnableBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0)); break; + case IDC_DEBUGGER_BP_LIST: + EnableBreak(SendDlgItemMessage(hwndDlg,IDC_DEBUGGER_BP_LIST,LB_GETCURSEL,0,0)); + break; // ################################## Start of SP CODE ########################### case LIST_DEBUGGER_BOOKMARKS: GoToDebuggerBookmark(hwndDlg); break;