tools/source/generic/fract.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
New commits: commit b9ec72ff4d2fb89002ab81e363712fbfd4cbfd98 Author: Noel Grandin <[email protected]> AuthorDate: Thu Oct 27 14:30:20 2022 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Thu Oct 27 15:24:35 2022 +0200 add some more asserts in Fraction::MakeFraction which I missed when inlining code in commit 8ac4dd510bd5f41882db0b647797674b06339f4e Author: Noel Grandin <[email protected]> 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 <[email protected]> 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;
