From b8d689422f7cc0cf73f3c922484e535c322c099e Mon Sep 17 00:00:00 2001 From: Igor Korot Date: Thu, 9 Jan 2020 17:40:51 -0600 Subject: [PATCH] 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 --- docs/changes.txt | 3 +++ src/msw/listctrl.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index c666ed9dbb..ffb05b5c70 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 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 ----------------------------------------------------- diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 5f6f922854..89456899bb 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1077,6 +1077,9 @@ bool wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId // Gets the item state 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; info.m_mask = wxLIST_MASK_STATE;