From 29bf859fae9116f591907af36ee04cb07459ba0b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 29 Nov 2014 16:45:21 +0000 Subject: [PATCH] Check if new index is in range before selecting new value in wxPGProperty::SetChoiceSelection. Closes #16697 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/property.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index 740cb00284..32a08769a4 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -1999,12 +1999,14 @@ int wxPGProperty::GetChoiceSelection() const void wxPGProperty::SetChoiceSelection( int newValue ) { + wxCHECK_RET( m_choices.IsOk(), wxT("invalid choiceinfo") ); + wxCHECK_RET( newValue >= 0 && newValue < (int)m_choices.GetCount(), + wxT("New index is out of range") ); + // Changes value of a property with choices, but only // works if the value type is long or string. wxString valueType = GetValue().GetType(); - wxCHECK_RET( m_choices.IsOk(), wxT("invalid choiceinfo") ); - if ( valueType == wxPG_VARIANT_TYPE_STRING ) { SetValue( m_choices.GetLabel(newValue) );