From b351612821e782d26713c4ab53382bf628bf1bd1 Mon Sep 17 00:00:00 2001
From: Xisco Fauli <xiscofauli@libreoffice.org>
Date: Tue, 21 Jun 2022 16:58:24 +0200
Subject: svtools: avoid divide by zero in calcCustomItemSize
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

See https://crashreport.libreoffice.org/stats/signature/%60anonymous%20namespace'::calcCustomItemSize

Change-Id: I5f1b19b7679c73cf29952629469e5151395b2b12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136254
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit ec03eef9b431048ea21a733c39c79b792b0f653c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136393
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136451
---
 svtools/source/control/ctrlbox.cxx | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 0b1c67e31980..393eea9e80fd 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -343,7 +343,8 @@ namespace
         gUserItemSz.setHeight(gUserItemSz.Height() / 10);
 
         size_t nMaxDeviceHeight = SAL_MAX_INT16 / 2; // see limitXCreatePixmap
-        gPreviewsPerDevice = nMaxDeviceHeight / gUserItemSz.Height();
+        assert(gUserItemSz.Height() != 0);
+        gPreviewsPerDevice = gUserItemSz.Height() == 0 ? 16 : nMaxDeviceHeight / gUserItemSz.Height();
     }
 }
 
-- 
cgit