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

New commits:
commit 9b2d3afe413f3bffcee169bd48d945f849896b7f
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 20 11:49:44 2022 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Jun 1 22:45:39 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>
    (cherry picked from commit ce39195e533336ce1482e2be6b1bec2b7f992125)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134627
    (cherry picked from commit def9e701c83e7283b3580490c881a5b692c4ec12)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134779
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/vcl/source/control/fmtfield.cxx b/vcl/source/control/fmtfield.cxx
index 326ba7f7ef3e..a0d96dd9caae 100644
--- a/vcl/source/control/fmtfield.cxx
+++ b/vcl/source/control/fmtfield.cxx
@@ -1183,7 +1183,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
@@ -1204,7 +1204,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