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

coverity#1430077 add assert for 'Division or modulo by zero'

and

coverity#1430076 Division or modulo by zero
coverity#1430078 Division or modulo by float zero
coverity#1430082 Division or modulo by float zero
coverity#1430083 Division or modulo by zero
coverity#1430085 Division or modulo by zero
coverity#1430102 Division or modulo by zero
coverity#1430103 Division or modulo by zero

Change-Id: I9d7190f95d19a755c681f1f897a8921105ef7c46
Reviewed-on: https://gerrit.libreoffice.org/51568Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 864c129a
......@@ -65,7 +65,9 @@ public:
{
tools::Rectangle aTemp = m_aComboListBox.GetDropDownPosSizePixel();
Size aSize = aTemp.GetSize();
aSize.setHeight( aSize.Height() / m_aComboListBox.GetDisplayLineCount() );
sal_uInt16 nLineCount = m_aComboListBox.GetDisplayLineCount();
assert(nLineCount && "div-by-zero");
aSize.setHeight( aSize.Height() / nLineCount );
Point aTopLeft = aTemp.TopLeft();
aTopLeft.AdjustY( aSize.Height() * ( nItem - m_aComboListBox.GetTopEntry() ) );
aRect = tools::Rectangle( aTopLeft, aSize );
......
......@@ -529,6 +529,7 @@ IMPL_LINK( SvxGrfCropPage, CropHdl, SpinField&, rField, void )
if(bZoom && ( ( ( aOrigSize.Height() - (nTop + nBottom )) * nHeightZoom)
/ 100 >= aPageSize.Height()))
{
assert(nHeightZoom && "div-by-zero");
if(&rField == m_pTopMF)
{
nTop = aOrigSize.Height() -
......
......@@ -678,10 +678,14 @@ void ScDrawLayer::ResizeLastRectFromAnchor(const SdrObject* pObj, ScDrawObjData&
tools::Rectangle aRectIncludingOffset = aRect;
aRectIncludingOffset.setWidth(aRect.GetWidth() + rData.maStartOffset.X());
aRectIncludingOffset.setHeight(aRect.GetHeight() + rData.maStartOffset.Y());
long nWidth = aRectIncludingOffset.GetWidth();
assert(nWidth && "div-by-zero");
double fMaxWidthFactor = static_cast<double>(aCurrentCellRect.GetWidth())
/ static_cast<double>(aRectIncludingOffset.GetWidth());
/ static_cast<double>(nWidth);
long nHeight = aRectIncludingOffset.GetHeight();
assert(nHeight && "div-by-zero");
double fMaxHeightFactor = static_cast<double>(aCurrentCellRect.GetHeight())
/ static_cast<double>(aRectIncludingOffset.GetHeight());
/ static_cast<double>(nHeight);
double fMaxFactor = std::min(fMaxHeightFactor, fMaxWidthFactor);
if (bIsGrowingLarger) // cell is growing larger
......
......@@ -201,6 +201,7 @@ ScRange ScSamplingDialog::PerformPeriodicSampling(ScDocShell* pDocShell)
outRow = mOutputAddress.Row();
for (SCROW inRow = aStart.Row(); inRow <= aEnd.Row(); inRow++)
{
assert(aPeriod && "div-by-zero");
if (i % aPeriod == aPeriod - 1 ) // Sample the last of period
{
double aValue = mDocument->GetValue(ScAddress(inCol, inRow, inTab));
......
......@@ -558,8 +558,12 @@ void ScDrawView::FitToCellSize()
// For graphic objects, we want to keep the aspect ratio
if (pObj->shouldKeepAspectRatio())
{
double fScaleX = static_cast<double>(aCellRect.GetWidth()) / static_cast<double>(aGraphicRect.GetWidth());
double fScaleY = static_cast<double>(aCellRect.GetHeight()) / static_cast<double>(aGraphicRect.GetHeight());
long nWidth = aGraphicRect.GetWidth();
assert(nWidth && "div-by-zero");
double fScaleX = static_cast<double>(aCellRect.GetWidth()) / static_cast<double>(nWidth);
long nHeight = aGraphicRect.GetHeight();
assert(nHeight && "div-by-zero");
double fScaleY = static_cast<double>(aCellRect.GetHeight()) / static_cast<double>(nHeight);
double fScaleMin = std::min(fScaleX, fScaleY);
aCellRect.setWidth(static_cast<double>(aGraphicRect.GetWidth()) * fScaleMin);
......
......@@ -172,7 +172,9 @@ void SdVectorizeDlg::Calculate( Bitmap const & rBmp, GDIMetaFile& rMtf )
const long nHeight = pRAcc->Height();
const long nTileX = static_cast<long>(m_pMtFillHoles->GetValue());
const long nTileY = static_cast<long>(m_pMtFillHoles->GetValue());
assert(nTileX && "div-by-zero");
const long nCountX = nWidth / nTileX;
assert(nTileY && "div-by-zero");
const long nCountY = nHeight / nTileY;
const long nRestX = nWidth % nTileX;
const long nRestY = nHeight % nTileY;
......
......@@ -573,8 +573,11 @@ void SwSendMailDialog::UpdateTransferStatus()
sStatus = m_sErrorStatus.replaceFirst("%1", OUString::number(m_nErrorCount) );
m_pErrorStatus->SetText(sStatus);
if(m_pImpl->aDescriptors.size())
if (m_pImpl->aDescriptors.size())
{
assert(m_nExpectedCount && "div-by-zero");
m_pProgressBar->SetValue(static_cast<sal_uInt16>(m_nSendCount * 100 / m_nExpectedCount));
}
else
m_pProgressBar->SetValue(0);
}
......
......@@ -417,7 +417,9 @@ IMPL_LINK(SwTextGridPage, CharorLineChangedHdl, SpinField&, rField, void)
}
else if (m_pCharsPerLineNF == &rField)
{
long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / m_pCharsPerLineNF->GetValue());
auto nValue = m_pCharsPerLineNF->GetValue();
assert(nValue && "div-by-zero");
long nWidth = static_cast< sal_Int32 >(m_aPageSize.Width() / nValue);
m_pCharWidthMF->SetValue(m_pCharWidthMF->Normalize(nWidth), FUNIT_TWIP);
SetLinesOrCharsRanges( *m_pCharsRangeFT , m_pCharsPerLineNF->GetMax() );
}
......
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