Kaydet (Commit) c4e53fad authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1078537 Division or modulo by zero

Change-Id: I63e8168efe169e506b3be65ca150a779404f0885
üst 54ba9587
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "htmltbl.hxx" #include "htmltbl.hxx"
#include "ndindex.hxx" #include "ndindex.hxx"
#include "switerator.hxx" #include "switerator.hxx"
#include <o3tl/numeric.hxx>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#ifdef DBG_UTIL #ifdef DBG_UTIL
#include "tblrwcl.hxx" #include "tblrwcl.hxx"
...@@ -1417,10 +1418,12 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv ...@@ -1417,10 +1418,12 @@ void SwHTMLTableLayout::AutoLayoutPass2( sal_uInt16 nAbsAvail, sal_uInt16 nRelAv
} }
OSL_ENSURE( nCols==nFixedCols, "Missed a column!" ); 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. // 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(); sal_uLong nColMax = GetColumn( i )->GetMax();
GetColumn( i )->SetAbsColWidth( GetColumn( i )->SetAbsColWidth(
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <poolfmt.hxx> #include <poolfmt.hxx>
#include <tblrwcl.hxx> #include <tblrwcl.hxx>
#include <unochart.hxx> #include <unochart.hxx>
#include <o3tl/numeric.hxx>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
...@@ -1904,6 +1905,8 @@ static void lcl_CopyBoxToDoc(_FndBox const& rFndBox, _CpyPara *const pCpyPara) ...@@ -1904,6 +1905,8 @@ static void lcl_CopyBoxToDoc(_FndBox const& rFndBox, _CpyPara *const pCpyPara)
{ {
nRealSize = pCpyPara->nNewSize; nRealSize = pCpyPara->nNewSize;
nRealSize *= rFndBox.GetBox()->GetFrmFmt()->GetFrmSize().GetWidth(); nRealSize *= rFndBox.GetBox()->GetFrmFmt()->GetFrmSize().GetWidth();
if (pCpyPara->nOldSize == 0)
throw o3tl::divide_by_zero();
nRealSize /= pCpyPara->nOldSize; nRealSize /= pCpyPara->nOldSize;
} }
......
...@@ -2968,14 +2968,14 @@ bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth ) ...@@ -2968,14 +2968,14 @@ bool SwCollectTblLineBoxes::Resize( sal_uInt16 nOffset, sal_uInt16 nOldWidth )
aPosArr.erase( aPosArr.begin(), aPosArr.begin() + n ); aPosArr.erase( aPosArr.begin(), aPosArr.begin() + n );
m_Boxes.erase(m_Boxes.begin(), m_Boxes.begin() + n); m_Boxes.erase(m_Boxes.begin(), m_Boxes.begin() + n);
size_t nSize = aPosArr.size(); size_t nArrSize = aPosArr.size();
if (nSize) if (nArrSize)
{ {
if (nOldWidth == 0) if (nOldWidth == 0)
throw o3tl::divide_by_zero(); throw o3tl::divide_by_zero();
// Adapt the positions to the new Size // Adapt the positions to the new Size
for( n = 0; n < nSize; ++n ) for( n = 0; n < nArrSize; ++n )
{ {
sal_uLong nSize = nWidth; sal_uLong nSize = nWidth;
nSize *= ( aPosArr[ n ] - nOffset ); nSize *= ( aPosArr[ n ] - nOffset );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment