include/tools/bigint.hxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit a2a02508d5aa6332c71245bb13f4c40f61790a72 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Dec 20 13:48:11 2023 +0300 Commit: Mike Kaganski <[email protected]> CommitDate: Wed Dec 20 20:30:10 2023 +0100 Fix BigInt::Abs It would fail to negate SAL_MIN_INT32. Change-Id: Ia5d34fc31917cabee2a1b130ef69c91b202592fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161063 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/tools/bigint.hxx b/include/tools/bigint.hxx index 644bb4c3e29d..2b7d9870d3e3 100644 --- a/include/tools/bigint.hxx +++ b/include/tools/bigint.hxx @@ -187,7 +187,16 @@ inline BigInt BigInt::Abs() const if (IsBig()) aRes.bIsNeg = false; else if ( nVal < 0 ) - aRes.nVal = -nVal; + { + if (nVal == std::numeric_limits<sal_Int32>::min()) + { + aRes.nNum[0] = -sal_Int64(std::numeric_limits<sal_Int32>::min()); + aRes.nLen = 1; + aRes.bIsNeg = false; + } + else + aRes.nVal = -nVal; + } return aRes; }
