From bf6fee0af9b4cf7b4ff0a289992fa4f02488b27d Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 29 Dec 2020 18:07:20 -0800 Subject: [PATCH] Avoid array overrun in OSX's wxCheckListBox::IsChecked --- src/osx/checklst_osx.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osx/checklst_osx.cpp b/src/osx/checklst_osx.cpp index ba95b138e9..134e778338 100644 --- a/src/osx/checklst_osx.cpp +++ b/src/osx/checklst_osx.cpp @@ -83,7 +83,13 @@ bool wxCheckListBox::IsChecked(unsigned int n) const wxCHECK_MSG( IsValid(n), false, wxT("invalid index in wxCheckListBox::IsChecked") ); - return m_checks[n] != 0; + // It's possible that m_checks has not yet been expanded to match the + // wxCheckListBox::GetCount() value (for example while in the midst of + // appending a new item) so double-check that we don't read beyond the end + // of the array. + if (n < m_checks.size()) + return m_checks[n] != 0; + return false; } void wxCheckListBox::Check(unsigned int n, bool check)