summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-10-29 09:48:58 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-10-29 10:40:09 +0000
commitc4e53fadbd9d4d5444547a18269eea5c54fd7a89 (patch)
tree0a8241e8df15ba70af3cd5c32d42209738133b14 /sw
parent54ba9587c0f1d3b5206742339af4907047fb4748 (diff)
coverity#1078537 Division or modulo by zero
Change-Id: I63e8168efe169e506b3be65ca150a779404f0885
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/htmltbl.cxx7
-rw-r--r--sw/source/core/doc/tblrwcl.cxx3
-rw-r--r--sw/source/core/docnode/ndtbl.cxx6
3 files changed, 11 insertions, 5 deletions
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index 8ad649745a98..ba18c2710611 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -40,6 +40,7 @@
#include "htmltbl.hxx"
#include "ndindex.hxx"
#include "switerator.hxx"
+#include <o3tl/numeric.hxx>
#include <boost/foreach.hpp>
#ifdef DBG_UTIL
#include "tblrwcl.hxx"
@@ -1417,10 +1418,12 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
}
OSL_ENSURE( nCols==nFixedCols, "Missed a column!" );
}
- else
+ else if (nCols > 0)
{
+ if (nMax == 0)
+ throw o3tl::divide_by_zero();
// No. So distribute the space regularly among all columns.
- for( sal_uInt16 i=0; i<nCols; i++ )
+ for (sal_uInt16 i=0; i < nCols; ++i)
{
sal_uLong nColMax = GetColumn( i )->GetMax();
GetColumn( i )->SetAbsColWidth(
diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx
index 1ce8a372c978..2565bf0d008f 100644
--- a/sw/source/core/doc/tblrwcl.cxx
+++ b/sw/source/core/doc/tblrwcl.cxx
@@ -55,6 +55,7 @@
#include <poolfmt.hxx>
#include <tblrwcl.hxx>
#include <unochart.hxx>
+#include <o3tl/numeric.hxx>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/foreach.hpp>
@@ -1904,6 +1905,8 @@ static void lcl_CopyBoxToDoc(_FndBox const& rFndBox, _CpyPara *const pCpyPara)
{
nRealSize = pCpyPara->nNewSize;
nRealSize *= rFndBox.GetBox()->GetFrmFmt()->GetFrmSize().GetWidth();
+ if (pCpyPara->nOldSize == 0)
+ throw o3tl::divide_by_zero();
nRealSize /= pCpyPara->nOldSize;
}
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 25747f38a3fe..568493b5df00 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2968,14 +2968,14 @@ bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth )
aPosArr.erase( aPosArr.begin(), aPosArr.begin() + n );
m_Boxes.erase(m_Boxes.begin(), m_Boxes.begin() + n);
- size_t nSize = aPosArr.size();
- if (nSize)
+ size_t nArrSize = aPosArr.size();
+ if (nArrSize)
{
if (nOldWidth == 0)
throw o3tl::divide_by_zero();
// Adapt the positions to the new Size
- for( n = 0; n < nSize; ++n )
+ for( n = 0; n < nArrSize; ++n )
{
sal_uLong nSize = nWidth;
nSize *= ( aPosArr[ n ] - nOffset );