Skip to content

Commit

Permalink
Check that rows in wxDataViewListCtrl have the right size
Browse files Browse the repository at this point in the history
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 wxWidgets#724
  • Loading branch information
Kvaz1r authored and vadz committed Feb 17, 2018
1 parent 958d008 commit 3567cd5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/datavcmn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand All @@ -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 );
Expand Down

0 comments on commit 3567cd5

Please sign in to comment.