summaryrefslogtreecommitdiff
path: root/writerfilter/source/dmapper/DomainMapperTableManager.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-28 11:35:18 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-10-28 15:06:31 +0000
commit04343704ae9e5b2be4a47f7ba8ef35174db7076d (patch)
tree549f1a3aeb8158f68af0be5b9848c4b881f1340c /writerfilter/source/dmapper/DomainMapperTableManager.cxx
parent1f6aefcf2dc50a678561c9b3884d973481788821 (diff)
coverity#1000600 Division or modulo by zero
Change-Id: I38fb8a7072eb7905f5dccc8697b3176d8b34c6c2
Diffstat (limited to 'writerfilter/source/dmapper/DomainMapperTableManager.cxx')
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index c5b1946d6195..cbb32a8a60df 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -787,12 +787,19 @@ void DomainMapperTableManager::endOfRowAction()
for (sal_uInt32 i = 0; i < pCellWidths->size(); ++i)
nFullWidthRelative += (*pCellWidths.get())[i];
- for (sal_uInt32 i = 0; i < pCellWidths->size() - 1; ++i)
+ size_t nWidthsBound = pCellWidths->size() - 1;
+ if (nWidthsBound)
{
- nSum += (*pCellWidths.get())[i];
- pSeparators[nPos].Position = (nSum * 10000) / nFullWidthRelative; // Relative position
- pSeparators[nPos].IsVisible = sal_True;
- nPos++;
+ if (nFullWidthRelative == 0)
+ throw std::range_error("divide by zero");
+
+ for (sal_uInt32 i = 0; i < nWidthsBound; ++i)
+ {
+ nSum += (*pCellWidths.get())[i];
+ pSeparators[nPos].Position = (nSum * 10000) / nFullWidthRelative; // Relative position
+ pSeparators[nPos].IsVisible = sal_True;
+ nPos++;
+ }
}
TablePropertyMapPtr pPropMap( new TablePropertyMap );