svx/source/dialog/charmap.cxx    |    2 ++
 sw/source/core/layout/atrfrm.cxx |    1 +
 sw/source/core/text/frmpaint.cxx |    2 ++
 sw/source/core/text/porrst.cxx   |    1 +
 vcl/source/control/fmtfield.cxx  |    2 ++
 5 files changed, 8 insertions(+)

New commits:
commit 4dae3508de6d2340562f0c97ca4d00b03dcae42d
Author:     Xisco Fauli <[email protected]>
AuthorDate: Mon Jun 6 11:25:02 2022 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Jun 10 09:15:46 2022 +0200

    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
    7c8b9fa98f4c5f7f5620e797dbbe24081e252548
    fae937b6859517bd9fe8e400cad3c84561ff98ab
    ce39195e533336ce1482e2be6b1bec2b7f992125
    23e3bff528ab38c8d5c6d401b672a0033cef2bd4
    ea4cd397300120a0f825752182eb3b943eb8a1b2
    
    Change-Id: I175f47361e07961417c87cc8f3d7d4d1fb50fb2c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135448
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index d7a7898d5342..6eb9745c8233 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -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);
 }
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 98588785cec3..2fcc7987d97b 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -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)
     {
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 8637faca988c..36885753e514 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -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());
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 498d1006108a..5e3d6921292d 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -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());
diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 3aee3317c829..359856c64486 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -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;

Reply via email to