diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-20 11:49:44 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-05-22 14:51:01 +0200 |
commit | def9e701c83e7283b3580490c881a5b692c4ec12 (patch) | |
tree | 01bbd3e8f492899bcb842c8097ac1b437b7950a1 /vcl/source | |
parent | 3a1db3389993fe9a52330fe36bb7bdfcea905242 (diff) |
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
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/control/fmtfield.cxx | 4 |
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 |