editeng/source/editeng/impedit3.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 9d01f5711e1e42ac7cec57408cc41329f5e9c892
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Dec 20 11:10:03 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Dec 21 07:22:36 2022 +0000

    editeng: avoid divide by zero
    
    Prevent mnColumns from ending up in a zero state.
    
    See
    
https://crashreport.libreoffice.org/stats/signature/ImpEditEngine::CreateAndInsertEmptyLine(ParaPortion%20*)
    
    Change-Id: I9137a0de33743ba514526cc28f4afef018de3614
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144580
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    (cherry picked from commit d35d01937ac77a12b06c1884dae2ec53998cf088)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144598
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 7d59b24f7599..db6f71b6d4d3 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2660,8 +2660,14 @@ void ImpEditEngine::SetRotation(TextRotation nRotation)
 
 void ImpEditEngine::SetTextColumns(sal_Int16 nColumns, sal_Int32 nSpacing)
 {
+    assert(nColumns >= 1);
     if (mnColumns != nColumns || mnColumnSpacing != nSpacing)
     {
+        if (nColumns == 0)
+        {
+            SAL_WARN("editeng", "bad nColumns value, ignoring");
+            nColumns = 1;
+        }
         mnColumns = nColumns;
         mnColumnSpacing = nSpacing;
         if (IsFormatted())

Reply via email to