Check that rows in wxDataViewListCtrl have the right size

Vectors passed to wxDataViewListCtrl::{Append,Insert,Prepend}Item()
functions must have the correct, i.e. equal to the column count, number
of items as otherwise accessing them later would result in a crash.

Add checks verifying that this is indeed the case.

Closes https://github.com/wxWidgets/wxWidgets/pull/724
This commit is contained in:
Kvaz1r
2018-02-16 21:02:54 +02:00
committed by Vadim Zeitlin
parent 958d0081a5
commit 3567cd5b00

View File

@@ -2209,6 +2209,7 @@ wxString wxDataViewListStore::GetColumnType( unsigned int pos ) const
void wxDataViewListStore::AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data )
{
wxCHECK_RET( values.size() == GetColumnCount(), "wrong number of values" );
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.push_back( line );
@@ -2218,6 +2219,7 @@ void wxDataViewListStore::AppendItem( const wxVector<wxVariant> &values, wxUIntP
void wxDataViewListStore::PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data )
{
wxCHECK_RET( values.size() == GetColumnCount(), "wrong number of values" );
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.insert( m_data.begin(), line );
@@ -2228,6 +2230,7 @@ void wxDataViewListStore::PrependItem( const wxVector<wxVariant> &values, wxUInt
void wxDataViewListStore::InsertItem( unsigned int row, const wxVector<wxVariant> &values,
wxUIntPtr data )
{
wxCHECK_RET( values.size() == GetColumnCount(), "wrong number of values" );
wxDataViewListStoreLine *line = new wxDataViewListStoreLine( data );
line->m_values = values;
m_data.insert( m_data.begin()+row, line );