diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-05-31 13:42:23 +0200 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2022-07-01 11:29:24 +0200 |
commit | d5875107e505802ab8de9e759e295ed12b36e22b (patch) | |
tree | 7ade9cf8b375327d98e4888d2abe312f2b9f21e5 | |
parent | tdf#149787 capture a copy of mpViewShell and mpView (diff) | |
download | core-d5875107e505802ab8de9e759e295ed12b36e22b.tar.gz core-d5875107e505802ab8de9e759e295ed12b36e22b.zip |
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 <xiscofauli@libreoffice.org>
(cherry picked from commit aeeb0141aca4f1698b09bc8f06ded41247b54279)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135255
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | sw/source/core/table/swtable.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
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 ) { |