From 44b938040f312def227c9ed72d1f83811cf67f1a Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 6 Jan 2018 21:01:32 +0000 Subject: ofz#4995 Integer-overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iad6e1c90cb099077809cc5684f683a0ba25b303b Reviewed-on: https://gerrit.libreoffice.org/47519 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- tools/source/generic/bigint.cxx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tools/source') diff --git a/tools/source/generic/bigint.cxx b/tools/source/generic/bigint.cxx index 883e3804617d..e4afdb6be55e 100644 --- a/tools/source/generic/bigint.cxx +++ b/tools/source/generic/bigint.cxx @@ -51,17 +51,19 @@ void BigInt::MakeBigInt( const BigInt& rVal ) } else { - sal_Int32 nTmp = rVal.nVal; - - nVal = rVal.nVal; + nVal = rVal.nVal; bIsBig = true; - if ( nTmp < 0 ) + sal_uInt32 nTmp; + if (nVal < 0) { bIsNeg = true; - nTmp = -nTmp; + nTmp = -static_cast(nVal); } else + { bIsNeg = false; + nTmp = nVal; + } nNum[0] = (sal_uInt16)(nTmp & 0xffffL); nNum[1] = (sal_uInt16)(nTmp >> 16); -- cgit