From c53524a59ba39871269dfacbcee2187ab8776d69 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jun 2018 23:18:28 +0200 Subject: [PATCH] Also check the old selection index for validity It's not totally clear if the old selection is always guaranteed to be valid so prefer to check it explicitly. --- src/osx/listbox_osx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index b00514c94f..ff41b53a37 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -444,7 +444,7 @@ void wxListBox::MacHandleSelectionChange(int row) if ( !m_oldSelections.empty() ) { const int oldsel = m_oldSelections[0]; - if (oldsel >= 0) + if ( oldsel >= 0 && oldsel < count ) SetSelection(oldsel); } }