diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-07-25 21:50:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-07-25 22:35:46 +0200 |
commit | 3f88c646a911e4b25f4866eda75ac38b978c4fd0 (patch) | |
tree | c9604eb810894e5a2b32eabb37a14775ea212b86 /sd | |
parent | 134f40136a9bea265d8f2fedfdb41a1e65d81b49 (diff) |
Avoid some division by zero
...as seen when running under UBSan `instdir/program/soffice --headless
--convert-to epub` of caolan/SIGSEGV-270412-142321-SIGSEGV-150412-121455-91.pptx
from the crash-testing corpus
Change-Id: I7ce0151689f90b8cba7cd86d053f327fdccc82d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119487
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/sdwindow.cxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx index c69b0cf3211b..8c0d58f50cec 100644 --- a/sd/source/ui/view/sdwindow.cxx +++ b/sd/source/ui/view/sdwindow.cxx @@ -630,7 +630,7 @@ void Window::UpdateMapMode() */ double Window::GetVisibleX() const { - return (static_cast<double>(maWinPos.X()) / maViewSize.Width()); + return maViewSize.Width() == 0 ? 0 : (static_cast<double>(maWinPos.X()) / maViewSize.Width()); } /** @@ -639,7 +639,7 @@ double Window::GetVisibleX() const */ double Window::GetVisibleY() const { - return (static_cast<double>(maWinPos.Y()) / maViewSize.Height()); + return maViewSize.Height() == 0 ? 0 : (static_cast<double>(maWinPos.Y()) / maViewSize.Height()); } /** @@ -669,7 +669,8 @@ double Window::GetVisibleWidth() const Size aWinSize = PixelToLogic(GetOutputSizePixel()); if ( aWinSize.Width() > maViewSize.Width() ) aWinSize.setWidth( maViewSize.Width() ); - return (static_cast<double>(aWinSize.Width()) / maViewSize.Width()); + return + maViewSize.Width() == 0 ? 0 : (static_cast<double>(aWinSize.Width()) / maViewSize.Width()); } /** @@ -681,7 +682,8 @@ double Window::GetVisibleHeight() const Size aWinSize = PixelToLogic(GetOutputSizePixel()); if ( aWinSize.Height() > maViewSize.Height() ) aWinSize.setHeight( maViewSize.Height() ); - return (static_cast<double>(aWinSize.Height()) / maViewSize.Height()); + return maViewSize.Height() == 0 + ? 0 : (static_cast<double>(aWinSize.Height()) / maViewSize.Height()); } Point Window::GetVisibleCenter() |