tools/source/generic/bigint.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
New commits: commit 71da7445e50eadfce261fcd2f82d16cbaa017041 Author: Caolán McNamara <[email protected]> Date: Mon Jan 8 09:58:31 2018 +0000 ofz#5000 Integer-overflow Change-Id: I74871848ddddafd1a89ddb3eee4a307cc5d7c16b Reviewed-on: https://gerrit.libreoffice.org/47573 Tested-by: Jenkins <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index cda2be1843d7..6fa9a2c472f0 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -330,21 +330,21 @@ void BigInt::DivLong( const BigInt& rB, BigInt& rErg ) const for (j = aTmpA.nLen - 1; j >= nLenB; j--) { // guess divisor - sal_Int32 nTmp = ( (sal_Int32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; + sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1]) nQ = 0xFFFF; else - nQ = (sal_uInt16)(((sal_uInt32)nTmp) / aTmpB.nNum[nLenB1]); + nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]); if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) > - ((((sal_uInt32)nTmp) - (sal_uInt32)aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) + ((nTmp - (sal_uInt32)aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) nQ--; // Start division nK = 0; for (i = 0; i < nLenB; i++) { - nTmp = (sal_Int32)aTmpA.nNum[j - nLenB + i] - - ((sal_Int32)aTmpB.nNum[i] * nQ) + nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i] + - ((sal_uInt32)aTmpB.nNum[i] * nQ) - nK; aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp; nK = (sal_uInt16) (nTmp >> 16); @@ -397,21 +397,21 @@ void BigInt::ModLong( const BigInt& rB, BigInt& rErg ) const for (j = aTmpA.nLen - 1; j >= nLenB; j--) { // Guess divisor - sal_Int32 nTmp = ( (sal_Int32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; + sal_uInt32 nTmp = ( (sal_uInt32)aTmpA.nNum[j] << 16 ) + aTmpA.nNum[j - 1]; if (aTmpA.nNum[j] == aTmpB.nNum[nLenB1]) nQ = 0xFFFF; else - nQ = (sal_uInt16)(((sal_uInt32)nTmp) / aTmpB.nNum[nLenB1]); + nQ = (sal_uInt16)(nTmp / aTmpB.nNum[nLenB1]); if ( ((sal_uInt32)aTmpB.nNum[nLenB1 - 1] * nQ) > - ((((sal_uInt32)nTmp) - aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) + ((nTmp - aTmpB.nNum[nLenB1] * nQ) << 16) + aTmpA.nNum[j - 2]) nQ--; // Start division nK = 0; for (i = 0; i < nLenB; i++) { - nTmp = (sal_Int32)aTmpA.nNum[j - nLenB + i] - - ((sal_Int32)aTmpB.nNum[i] * nQ) + nTmp = (sal_uInt32)aTmpA.nNum[j - nLenB + i] + - ((sal_uInt32)aTmpB.nNum[i] * nQ) - nK; aTmpA.nNum[j - nLenB + i] = (sal_uInt16)nTmp; nK = (sal_uInt16) (nTmp >> 16);
_______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
