diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-01 20:37:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-01 21:02:15 +0000 |
commit | 2149e924cbc32c370128c5f87a4f55c50c99e6bd (patch) | |
tree | c36cbdb815600f3368ed833bef54c502245f36c3 | |
parent | 169bc7c6c608215cf3805b84d617892c8bf487f4 (diff) |
coverity#1000600 Division or modulo by float zero
Change-Id: If39679b54ef1bb0a7af794c2f7a6186ebd69c2e0
-rw-r--r-- | writerfilter/source/dmapper/DomainMapperTableManager.cxx | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index f4bc4ddd12d1..06ed55e7400d 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -741,20 +741,27 @@ void DomainMapperTableManager::endOfRowAction() sal_Int16 nLastRelPos = 0; sal_uInt32 nBorderGridIndex = m_nGridBefore; - ::std::vector< sal_Int32 >::const_iterator aSpansIter = pCurrentSpans->begin( ); - for( sal_uInt32 nBorder = 0; nBorder < m_nCell.back( ) - 1; ++nBorder ) + size_t nWidthsBound = m_nCell.back( ) - 1; + if (nWidthsBound) { - double fGridWidth = 0.; - for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount ) - fGridWidth += (*pTableGrid.get())[nBorderGridIndex++]; + if (nFullWidthRelative == 0) + throw std::range_error("divide by zero"); - sal_Int16 nRelPos = - sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative); + ::std::vector< sal_Int32 >::const_iterator aSpansIter = pCurrentSpans->begin( ); + for( sal_uInt32 nBorder = 0; nBorder < nWidthsBound; ++nBorder ) + { + double fGridWidth = 0.; + for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount ) + fGridWidth += (*pTableGrid.get())[nBorderGridIndex++]; - pSeparators[nBorder].Position = nRelPos + nLastRelPos; - pSeparators[nBorder].IsVisible = sal_True; - nLastRelPos = nLastRelPos + nRelPos; - ++aSpansIter; + sal_Int16 nRelPos = + sal::static_int_cast< sal_Int16 >((fGridWidth * 10000) / nFullWidthRelative); + + pSeparators[nBorder].Position = nRelPos + nLastRelPos; + pSeparators[nBorder].IsVisible = sal_True; + nLastRelPos = nLastRelPos + nRelPos; + ++aSpansIter; + } } TablePropertyMapPtr pPropMap( new TablePropertyMap ); pPropMap->Insert( PROP_TABLE_COLUMN_SEPARATORS, uno::makeAny( aSeparators ) ); |