sw/source/core/table/swtable.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
New commits: commit 19a6adddec0f5a6ee771939a17f85bdde4a44ce3 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jun 6 10:43:15 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jun 7 13:41:33 2022 +0200 sw: Divide-by-zero follow-up of aeeb0141aca4f1698b09bc8f06ded41247b54279 "sw: avoid another EXCEPTION_INT_DIVIDE_BY_ZERO" Change-Id: I0b5cc10c4f7976a611f222f3d4c8764c5d04dba0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135443 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 89b6e50e4c1e..c2ff14822a8e 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -249,7 +249,8 @@ namespace template<class T> T lcl_MulDiv64(sal_uInt64 nA, sal_uInt64 nM, sal_uInt64 nD) { - return static_cast<T>((nA*nM)/nD); + assert(nD != 0); + return nD == 0 ? static_cast<T>(nA*nM) : static_cast<T>((nA*nM)/nD); } } @@ -299,8 +300,7 @@ static void lcl_ModifyBoxes( SwTableBoxes &rBoxes, const tools::Long nOld, SwFrameFormat *pFormat = rBox.GetFrameFormat(); sal_uInt64 nBox = pFormat->GetFrameSize().GetWidth(); nOriginalSum += nBox; - nBox *= nNew; - nBox = nOld == 0 ? nBox : nBox / nOld; + nBox = lcl_MulDiv64<sal_uInt64>(nBox, nNew, nOld); const sal_uInt64 nWishedSum = lcl_MulDiv64<sal_uInt64>(nOriginalSum, nNew, nOld) - nSum; if( nWishedSum > 0 ) {