Check item index in wxListCtrl::GetItemState() in wxMSW too

This was already the case in the generic version, but wxMSW one just
silently returned 0 for invalid item index.

Make it consistent with the other platforms and SetItemState() by
checking the index in it too.

Closes https://github.com/wxWidgets/wxWidgets/pull/1702
This commit is contained in:
Igor Korot
2020-01-09 17:40:51 -06:00
committed by Vadim Zeitlin
parent 64ac20536a
commit b8d689422f
2 changed files with 6 additions and 0 deletions

View File

@@ -87,6 +87,9 @@ Changes in behaviour not resulting in compilation errors
there is no highlighted menu item, instead of wxID_ANY used before, for there is no highlighted menu item, instead of wxID_ANY used before, for
consistency with wxMSW. consistency with wxMSW.
- wxListCtrl::GetItemState() in wxMSW now checks the passed in item index for
validity, as the generic version under the other platforms already did.
Changes in behaviour which may result in build errors Changes in behaviour which may result in build errors
----------------------------------------------------- -----------------------------------------------------

View File

@@ -1077,6 +1077,9 @@ bool wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId
// Gets the item state // Gets the item state
int wxListCtrl::GetItemState(long item, long stateMask) const int wxListCtrl::GetItemState(long item, long stateMask) const
{ {
wxCHECK_MSG( item >= 0 && item < GetItemCount(), 0,
wxS("invalid list control item index in GetItemState()") );
wxListItem info; wxListItem info;
info.m_mask = wxLIST_MASK_STATE; info.m_mask = wxLIST_MASK_STATE;