vcl/source/filter/png/PngImageWriter.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit bc4080c7fdb81eff5cc71d88ba1d7c5714047490
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Thu Feb 16 20:36:57 2023 +0000
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Feb 17 09:15:12 2023 +0000

    crashreporting: divide by zero, aPrefSize.Width() must have been 0 here
    
    Change-Id: I5ee2c1f4386c95c12fb821a3514cb732b220bb86
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147125
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
index fd5ba3c84e8e..f550d9951e64 100644
--- a/vcl/source/filter/png/PngImageWriter.cxx
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -170,9 +170,12 @@ static bool pngWrite(SvStream& rStream, const BitmapEx& 
rBitmapEx, int nCompress
         if (aBitmapEx.GetPrefMapMode().GetMapUnit() == MapUnit::Map100thMM)
         {
             Size aPrefSize(aBitmapEx.GetPrefSize());
-            sal_uInt32 nPrefSizeX = o3tl::convert(aSize.Width(), 100000, 
aPrefSize.Width());
-            sal_uInt32 nPrefSizeY = o3tl::convert(aSize.Height(), 100000, 
aPrefSize.Height());
-            png_set_pHYs(pPng, pInfo, nPrefSizeX, nPrefSizeY, 1);
+            if (aPrefSize.Width() && aPrefSize.Height())
+            {
+                sal_uInt32 nPrefSizeX = o3tl::convert(aSize.Width(), 100000, 
aPrefSize.Width());
+                sal_uInt32 nPrefSizeY = o3tl::convert(aSize.Height(), 100000, 
aPrefSize.Height());
+                png_set_pHYs(pPng, pInfo, nPrefSizeX, nPrefSizeY, 1);
+            }
         }
 
         png_set_compression_level(pPng, nCompressionLevel);

Reply via email to