diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-10-28 23:43:02 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-10-29 00:32:24 +0100 |
commit | 65f98610ddb9b3847aad0566e15b6087d0149464 (patch) | |
tree | 32d54926a3b8ceb8dedc1575f6b5e9cc90e88263 /sw | |
parent | 9d28748d4b6d97bf0d18956e9e0336d71d9fc718 (diff) |
sw: fix "long" overflow in lcl_CalcWish
0 + (1 * 32768 * 65536 / 65537) evaluates to -32767 with 32-bit MSVC
whereas with 64-bit GCC the result is +32767.
The multiplication overflows to 0x80000000 - so do that in 64 bits.
This fixes the JunitTest_sw_unoapi_4 failure in SwXTextTable on the
TableBorder property, where the wrong result caused MakeSelUnions()
to believe that the last cell is not visible and hence setting the
TableBorder property failed.
Change-Id: Idb10535ce5342cd83d7ab6aea07782a2034469eb
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/frmedt/tblsel.cxx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 99b4e9edc926..269cdd516434 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -1503,7 +1503,8 @@ static SwTwips lcl_CalcWish( const SwLayoutFrm *pCell, long nWish, while ( pTmp->GetPrev() ) { pTmp = static_cast<const SwLayoutFrm*>(pTmp->GetPrev()); - long nTmp = pTmp->GetFormat()->GetFrmSize().GetWidth(); + sal_Int64 nTmp = pTmp->GetFormat()->GetFrmSize().GetWidth(); + // multiply in 64-bit to avoid overflow here! nRet += ( bRTL ? ( -1 ) : 1 ) * nTmp * nAct / nWish; } pTmp = pTmp->GetUpper()->GetUpper(); |