tools/source/generic/fract.cxx |    3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 297f000c4968da9a61846d1b336d4fb77e01610c
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Feb 3 09:35:25 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Feb 3 15:54:51 2022 +0100

    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 <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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);

Reply via email to