sw/source/core/docnode/ndtbl1.cxx |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 779e6fbef37119e9ad0cd2f63915b23c5645dab3
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Sep 9 12:58:19 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Sep 10 15:34:03 2022 +0200

    move code depending on bBalance inside a block conditional on that
    
    entirely possible the divide by zero happens in a case where that
    result isn't needed anyway
    
    Change-Id: I3d4732903663f6cd76f525b46550b778790b05a2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139724
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/source/core/docnode/ndtbl1.cxx 
b/sw/source/core/docnode/ndtbl1.cxx
index c50995b42904..3411f4b25490 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -1662,12 +1662,15 @@ void SwDoc::AdjustCellWidth( const SwCursor& rCursor,
             }
             fTotalWish += aWish[i];
         }
-        assert(nCols);
-        const sal_uInt16 nEqualWidth = nCols ? nSelectedWidth / nCols : 0;
         // bBalance: Distribute the width evenly
-        for (sal_uInt16 & rn : aWish)
-            if ( rn && bBalance )
-                rn = nEqualWidth;
+        if (bBalance)
+        {
+            assert(nCols);
+            const sal_uInt16 nEqualWidth = nCols ? nSelectedWidth / nCols : 0;
+            for (sal_uInt16 & rn : aWish)
+                if (rn)
+                    rn = nEqualWidth;
+        }
     }
 
     const tools::Long nOldRight = aTabCols.GetRight();

Reply via email to