diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-10-27 14:30:20 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-10-27 15:24:35 +0200 |
commit | b9ec72ff4d2fb89002ab81e363712fbfd4cbfd98 (patch) | |
tree | 192507c46125af1325c470bfdb78085482fef529 /tools | |
parent | e6a1586ff90125245cf0f898af37bf568abdcddf (diff) |
add some more asserts in Fraction::MakeFraction
which I missed when inlining code in
commit 8ac4dd510bd5f41882db0b647797674b06339f4e
Author: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Thu Oct 27 08:48:25 2022 +0200
tdf#123419 optimise ImplMakeFraction
Change-Id: Ifd271ce89cea29a22d41b8e143e27df118f8df3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141906
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/generic/fract.cxx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index 8c8b91d0f857..4acd46cec404 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -499,11 +499,19 @@ Fraction Fraction::MakeFraction( tools::Long nN1, tools::Long nN2, tools::Long n if ( nD2 < 0 ) { i = -i; nD2 = -nD2; } // all positive; i sign + assert( nN1 >= std::numeric_limits<sal_Int32>::min() ); + assert( nN1 <= std::numeric_limits<sal_Int32>::max( )); + assert( nD1 >= std::numeric_limits<sal_Int32>::min() ); + assert( nD1 <= std::numeric_limits<sal_Int32>::max( )); + assert( nN2 >= std::numeric_limits<sal_Int32>::min() ); + assert( nN2 <= std::numeric_limits<sal_Int32>::max( )); + assert( nD2 >= std::numeric_limits<sal_Int32>::min() ); + assert( nD2 <= std::numeric_limits<sal_Int32>::max( )); + boost::rational<sal_Int32> a = toRational(i*nN1, nD1); boost::rational<sal_Int32> b = toRational(nN2, nD2); bool bFail = checked_multiply_by(a, b); - while ( bFail ) { if ( nN1 > nN2 ) nN1 = (nN1 + 1) / 2; |