diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-01 09:02:04 +0000 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2017-12-01 16:39:58 +0100 |
commit | 7f81a748d2860968c3843984da24426e9806e436 (patch) | |
tree | 34d9d2f1a88090a3cc82d173232c48246d0a07c8 /oox | |
parent | 2ce7b8c097bdce78f99fe9e38f8da00ff04ac844 (diff) |
ofz: check col/row bounds
Change-Id: Idaa38f400873372330dd06c14800c4a5018c79db
Reviewed-on: https://gerrit.libreoffice.org/45641
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/table/tableproperties.cxx | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index d4c5bdc56d39..a692ea3682c1 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<sal_Int32>(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<sal_Int32>(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 ) ) ); |