Improve assert checking line index validity in wxGenericListCtrl

Don't just check that the index is not -1, but also that it's valid,
which can catch other problems.

Also replace the ASSERT with CHECK to avoid dereferencing invalid
pointer, it's better to crash when trying to dereference a NULL one.
This commit is contained in:
Vadim Zeitlin 2023-07-24 13:49:02 +02:00
parent 57c71a4547
commit 8c1234ea66

View file

@ -845,7 +845,7 @@ protected:
// get the line data for the given index
wxListLineData *GetLine(size_t n) const
{
wxASSERT_MSG( n != (size_t)-1, wxT("invalid line index") );
wxCHECK_MSG( n < m_lines.size(), nullptr, wxT("invalid line index") );
wxListMainWindow *self = wxConstCast(this, wxListMainWindow);