From 7d1d5a847db8d3245a2694295a7c369586695ff8 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 1 Dec 2017 09:02:04 +0000 Subject: ofz: check col/row bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idaa38f400873372330dd06c14800c4a5018c79db Reviewed-on: https://gerrit.libreoffice.org/45639 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- oox/source/drawingml/table/tableproperties.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'oox/source') diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index e5bc4f0cc3d5..527b65829d17 100644 --- a/oox/source/drawingml/table/tableproperties.cxx +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -58,7 +58,8 @@ void CreateTableRows( const uno::Reference< XTableRows >& xTableRows, const std: xTableRows->insertByIndex( 0, rvTableRows.size() - 1 ); std::vector< TableRow >::const_iterator aTableRowIter( rvTableRows.begin() ); uno::Reference< container::XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW ); - for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ ) + sal_Int32 nCols = std::min(xIndexAccess->getCount(), rvTableRows.size()); + for (sal_Int32 n = 0; n < nCols; ++n) { Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); xPropSet->setPropertyValue( "Height", Any( static_cast< sal_Int32 >( aTableRowIter->getHeight() / 360 ) ) ); @@ -72,7 +73,8 @@ void CreateTableColumns( const Reference< XTableColumns >& xTableColumns, const xTableColumns->insertByIndex( 0, rvTableGrid.size() - 1 ); std::vector< sal_Int32 >::const_iterator aTableGridIter( rvTableGrid.begin() ); uno::Reference< container::XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW ); - for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ ) + sal_Int32 nCols = std::min(xIndexAccess->getCount(), rvTableGrid.size()); + for (sal_Int32 n = 0; n < nCols; ++n) { Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); xPropSet->setPropertyValue( "Width", Any( static_cast< sal_Int32 >( *aTableGridIter++ / 360 ) ) ); -- cgit