Add asserts to those places where I fixed a EXCEPTION_INT_DIVIDE_BY_ZERO

I found those crashes scraping https://crashreport.libreoffice.org/stats/
so those are blind fixes basically. Add these asserts,
hoping one day someone will hit them so we can find the root cause.

See
7c8b9fa98f
fae937b685
ce39195e53
23e3bff528
ea4cd39730

Change-Id: I175f47361e07961417c87cc8f3d7d4d1fb50fb2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135448
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Xisco Fauli 2022-06-06 11:25:02 +02:00
parent d701eff351
commit 4dae3508de
5 changed files with 8 additions and 0 deletions

View file

@ -376,7 +376,9 @@ Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const
int SvxShowCharSet::PixelToMapIndex( const Point& point) const
{
int nBase = FirstInView();
assert(nX != 0);
int x = nX == 0 ? 0 : (point.X() - m_nXGap)/nX;
assert(nY != 0);
int y = nY == 0 ? 0 : (point.Y() - m_nYGap)/nY;
return (nBase + x + y * COLUMN_COUNT);
}

View file

@ -1061,6 +1061,7 @@ void SwFormatCol::Calc( sal_uInt16 nGutterWidth, sal_uInt16 nAct )
rLastCol.SetLeft(nGutterHalf);
rLastCol.SetRight(0);
assert(nAct != 0);
//Convert the current width to the requested width.
for (SwColumn &rCol: m_aColumns)
{

View file

@ -83,11 +83,13 @@ public:
SwFont* GetFont() const { return m_pFnt.get(); }
void IncLineNr() { ++m_nLineNr; }
bool HasNumber() const {
assert( m_rLineInf.GetCountBy() != 0 );
if( m_rLineInf.GetCountBy() == 0 )
return false;
return !( m_nLineNr % m_rLineInf.GetCountBy() );
}
bool HasDivider() const {
assert( m_rLineInf.GetDividerCountBy() != 0 );
if( !m_nDivider || m_rLineInf.GetDividerCountBy() == 0 )
return false;
return !(m_nLineNr % m_rLineInf.GetDividerCountBy());

View file

@ -644,6 +644,7 @@ bool SwBookmarkPortion::DoPaint(SwTextPaintInfo const& rTextPaintInfo,
Size aSize(rFont.GetSize(rFont.GetActual()));
// use also the external leading (line gap) of the portion, but don't use
// 100% of it because i can't figure out how to baseline align that
assert(aSize.Height() != 0);
auto const nFactor = aSize.Height() > 0 ? (Height() * 95) / aSize.Height() : Height();
rFont.SetProportion(nFactor);
rFont.SetWeight(WEIGHT_THIN, rFont.GetActual());

View file

@ -1187,6 +1187,7 @@ void FormattedField::Up()
sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
assert(nSpinSize != 0);
sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize == 0 ? 0 : nValue % nSpinSize;
if (nValue >= 0)
nValue = (nRemainder == 0) ? nValue + nSpinSize : nValue + nSpinSize - nRemainder;
@ -1208,6 +1209,7 @@ void FormattedField::Down()
sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
assert(nSpinSize != 0);
sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize == 0 ? 0 : nValue % nSpinSize;
if (nValue >= 0)
nValue = (nRemainder == 0) ? nValue - nSpinSize : nValue - nRemainder;