diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-01-06 21:01:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-01-07 21:06:09 +0100 |
commit | 44b938040f312def227c9ed72d1f83811cf67f1a (patch) | |
tree | 52f3aec7d8a59013471302995635122813165538 | |
parent | 7df57f6993cab4ba0f1fccce92394c4dfe46f067 (diff) |
ofz#4995 Integer-overflow
Change-Id: Iad6e1c90cb099077809cc5684f683a0ba25b303b
Reviewed-on: https://gerrit.libreoffice.org/47519
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | tools/source/generic/bigint.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
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<sal_Int64>(nVal); } else + { bIsNeg = false; + nTmp = nVal; + } nNum[0] = (sal_uInt16)(nTmp & 0xffffL); nNum[1] = (sal_uInt16)(nTmp >> 16); |