From 3567cd5b00209b16350743df26c0b61bf635704c Mon Sep 17 00:00:00 2001 From: Kvaz1r Date: Fri, 16 Feb 2018 21:02:54 +0200 Subject: [PATCH] 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 --- src/common/datavcmn.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 9043cf3fd4..d2d253ca2d 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -2209,6 +2209,7 @@ wxString wxDataViewListStore::GetColumnType( unsigned int pos ) const void wxDataViewListStore::AppendItem( const wxVector &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 &values, wxUIntP void wxDataViewListStore::PrependItem( const wxVector &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 &values, wxUInt void wxDataViewListStore::InsertItem( unsigned int row, const wxVector &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 );