vcl/source/control/fmtfield.cxx |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit ce39195e533336ce1482e2be6b1bec2b7f992125
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 20 11:49:44 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri May 20 17:08:48 2022 +0200

    vcl: avoid EXCEPTION_INT_DIVIDE_BY_ZERO
    
    See 
https://crashreport.libreoffice.org/stats/signature/FormattedField::Down()
    or https://crashreport.libreoffice.org/stats/signature/FormattedField::Up()
    
    Change-Id: I30dfb06a1261a48a75b9d9c2380ed78121758ec2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134674
    Tested-by: Jenkins
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index f027ada878e5..c07b7e3ab3c5 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -1180,7 +1180,7 @@ void FormattedField::Up()
 
     sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
     sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
-    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue 
% nSpinSize;
+    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize 
== 0 ? 0 : nValue % nSpinSize;
     if (nValue >= 0)
         nValue = (nRemainder == 0) ? nValue + nSpinSize : nValue + nSpinSize - 
nRemainder;
     else
@@ -1201,7 +1201,7 @@ void FormattedField::Down()
 
     sal_Int64 nValue = std::round(rFormatter.GetValue() * nScale);
     sal_Int64 nSpinSize = std::round(rFormatter.GetSpinSize() * nScale);
-    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() ? 0 : nValue 
% nSpinSize;
+    sal_Int64 nRemainder = rFormatter.GetDisableRemainderFactor() || nSpinSize 
== 0 ? 0 : nValue % nSpinSize;
     if (nValue >= 0)
         nValue = (nRemainder == 0) ? nValue - nSpinSize : nValue - nRemainder;
     else

Reply via email to