summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-07-29 09:48:45 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-07-29 10:58:06 +0200
commite1fe04f117030400f07d207e0a3e35161ac464fa (patch)
tree0a98c0f493899857b2f978bed9efe095240b02de
parent6f8f757c7338dd890273235bae6917b3175e2f86 (diff)
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@redhat.com>
-rw-r--r--vcl/source/gdi/graph.cxx6
1 files changed, 4 insertions, 2 deletions
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);