From 2fa082f698e35d204ba000a674ef5aba92474dd8 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 21 May 2014 01:06:52 -0500 Subject: [PATCH] fix bug lp:1319839 --- pcbnew/dialogs/dialog_fp_lib_table.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index a2ed8f5d38..6d5bf405da 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -166,7 +166,9 @@ public: bool DeleteRows( size_t aPos, size_t aNumRows ) { - if( aPos + aNumRows <= rows.size() ) + // aPos may be a large positive, e.g. size_t(-1), and the sum of + // aPos+aNumRows may wrap here, so both ends of the range are tested. + if( aPos < rows.size() && aPos + aNumRows <= rows.size() ) { ROWS_ITER start = rows.begin() + aPos; rows.erase( start, start + aNumRows ); @@ -512,10 +514,13 @@ private: int rowCount = m_cur_grid->GetNumberRows(); int curRow = getCursorRow(); - m_cur_grid->DeleteRows( curRow ); + if( curRow >= 0 ) + { + m_cur_grid->DeleteRows( curRow ); - if( curRow && curRow == rowCount - 1 ) - m_cur_grid->SetGridCursor( curRow-1, getCursorCol() ); + if( curRow && curRow == rowCount - 1 ) + m_cur_grid->SetGridCursor( curRow-1, getCursorCol() ); + } } void moveUpHandler( wxMouseEvent& event )