sw/source/core/table/swtable.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
New commits: commit d5875107e505802ab8de9e759e295ed12b36e22b Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Tue May 31 13:42:23 2022 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Fri Jul 1 11:29:24 2022 +0200 sw: avoid another EXCEPTION_INT_DIVIDE_BY_ZERO See https://crashreport.libreoffice.org/stats/signature/lcl_ModifyBoxes Change-Id: I786bbf87734dd3963bd84caecc5c5f45693d42c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135185 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit aeeb0141aca4f1698b09bc8f06ded41247b54279) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135255 Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index da159df14bd2..7992b430328b 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; + nBox = lcl_MulDiv64<sal_uInt64>(nBox, nNew, nOld); const sal_uInt64 nWishedSum = lcl_MulDiv64<sal_uInt64>(nOriginalSum, nNew, nOld) - nSum; if( nWishedSum > 0 ) {