[Libreoffice-commits] core.git: vcl/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 29 08:58:40 UTC 2021


 vcl/source/gdi/graph.cxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit e1fe04f117030400f07d207e0a3e35161ac464fa
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Jul 29 09:48:45 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Thu Jul 29 10:58:06 2021 +0200

    Avoid some division by zero
    
    The first of which was seen when running under UBSan `instdir/program/soffice
    --headless --convert-to pdf` of caolan/id:002485,src:002216,op:havoc,rep:8.jpg
    from the crash-testing corpus.  The second one (when computing nGrfDPIy) was not
    observed, but lets assume that it could happen just as well, and keep the code
    symmetric.
    
    Change-Id: Idf9f9a84f3b05c7cfe3c66db753c73d2cbf812be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119650
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index 5e71e5d1a0d4..352073455e01 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -400,8 +400,10 @@ basegfx::B2DSize Graphic::GetPPI() const
     {
         const Size aGrf1000thInchSize = OutputDevice::LogicToLogic(
                 aGrfPrefMapModeSize, aGrfMap, MapMode(MapUnit::Map1000thInch));
-        nGrfDPIx = 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
-        nGrfDPIy = 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
+        nGrfDPIx = aGrf1000thInchSize.Width() == 0
+            ? 0.0 : 1000.0 * aGrfPixelSize.Width() / aGrf1000thInchSize.Width();
+        nGrfDPIy = aGrf1000thInchSize.Height() == 0
+            ? 0.0 : 1000.0 * aGrfPixelSize.Height() / aGrf1000thInchSize.Height();
     }
 
     return basegfx::B2DSize(nGrfDPIx, nGrfDPIy);


More information about the Libreoffice-commits mailing list