[Libreoffice-commits] core.git: tools/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 10 18:20:04 UTC 2021
tools/source/generic/fract.cxx | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
New commits:
commit db00a6d4d9935f4905c70d826b27139221e4a1c7
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Apr 10 16:17:01 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Apr 10 20:19:23 2021 +0200
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 at redhat.com>
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!");
More information about the Libreoffice-commits
mailing list