From 57e9abd61307aa069b2cb449d215896e97857f5e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 2 Aug 2009 00:59:31 +0000 Subject: [PATCH] Check indices validity better in wxGridStringTable. Calling GetValue(-1, -1) could crash as the code naively only checked upper boundary (and didn't use unsigned which would have made the extra check unnecessary but it's too late for this now). Closes #11044. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6cd125e280..2ce9f06c70 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -1144,7 +1144,8 @@ wxGridStringTable::wxGridStringTable( int numRows, int numCols ) wxString wxGridStringTable::GetValue( int row, int col ) { - wxCHECK_MSG( (row < GetNumberRows()) && (col < GetNumberCols()), + wxCHECK_MSG( (row >= 0 && row < GetNumberRows()) && + (col >= 0 && col < GetNumberCols()), wxEmptyString, wxT("invalid row or column index in wxGridStringTable") ); @@ -1153,7 +1154,8 @@ wxString wxGridStringTable::GetValue( int row, int col ) void wxGridStringTable::SetValue( int row, int col, const wxString& value ) { - wxCHECK_RET( (row < GetNumberRows()) && (col < GetNumberCols()), + wxCHECK_RET( (row >= 0 && row < GetNumberRows()) && + (col >= 0 && col < GetNumberCols()), wxT("invalid row or column index in wxGridStringTable") ); m_data[row][col] = value; -- 2.45.2