diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-04-10 16:17:01 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-04-10 20:19:23 +0200 |
commit | db00a6d4d9935f4905c70d826b27139221e4a1c7 (patch) | |
tree | 173563ef97342a7537a40d2c5df043d1c753a8c1 /tools/source | |
parent | a6e271621843f454d92bc2c73a4425ad4afd1211 (diff) |
ofz#32973 Integer-overflow
Change-Id: Ib290468b4c7388b80da627138435b98feaed354b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113921
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/generic/fract.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index d4c4fe11c319..7c0e850db8d7 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -427,8 +427,15 @@ static void rational_ReduceInaccurate(boost::rational<sal_Int32>& rRational, uns return; // http://www.boost.org/doc/libs/release/libs/rational/rational.html#Internal%20representation - const bool bNeg = ( rRational.numerator() < 0 ); - sal_Int32 nMul = bNeg? -rRational.numerator(): rRational.numerator(); + sal_Int32 nMul = rRational.numerator(); + if (nMul == std::numeric_limits<sal_Int32>::min()) + { + // ofz#32973 Integer-overflow + return; + } + const bool bNeg = nMul < 0; + if (bNeg) + nMul = -nMul; sal_Int32 nDiv = rRational.denominator(); DBG_ASSERT(nSignificantBits<65, "More than 64 bit of significance is overkill!"); |