diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-02-03 09:35:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-02-03 15:54:51 +0100 |
commit | 297f000c4968da9a61846d1b336d4fb77e01610c (patch) | |
tree | b6cf6ba25da353ad2a0739c902f0f95deea38fb7 /tools | |
parent | 50f4b6bfd5c71a66d0c50aad7a99408ce1b99d58 (diff) |
cid#1497939 Division or modulo by zero
and
cid#1497937 Division or modulo by zero
Change-Id: I24f939e19791d811845a476c68125f40bb78f9c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129400
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/fract.cxx | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index 93a92fb3a12a..078ffd87f387 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -182,6 +182,9 @@ namespace sal_Int32 gcd1 = std::gcd(i.numerator(), den); sal_Int32 gcd2 = std::gcd(num, i.denominator()); + if (!gcd1 || !gcd2) + return true; + bool fail = false; fail |= o3tl::checked_multiply(i.numerator() / gcd1, num / gcd2, num); fail |= o3tl::checked_multiply(i.denominator() / gcd2, den / gcd1, den); |