summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-05-20 11:49:44 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2022-06-01 22:45:39 +0200
commit9b2d3afe413f3bffcee169bd48d945f849896b7f (patch)
tree921179b7485f8fd8ff43ab21cc756b3ebcd45fac
parentsvx: fix one more EXCEPTION_INT_DIVIDE_BY_ZERO (diff)
downloadcore-9b2d3afe413f3bffcee169bd48d945f849896b7f.tar.gz
core-9b2d3afe413f3bffcee169bd48d945f849896b7f.zip
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 <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@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.behrens@allotropia.de> Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--vcl/source/control/fmtfield.cxx4
1 files changed, 2 insertions, 2 deletions
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