[Libreoffice-commits] core.git: sd/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jul 25 20:36:17 UTC 2021
sd/source/ui/view/sdwindow.cxx | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
New commits:
commit 3f88c646a911e4b25f4866eda75ac38b978c4fd0
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sun Jul 25 21:50:37 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sun Jul 25 22:35:46 2021 +0200
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 at redhat.com>
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()
More information about the Libreoffice-commits
mailing list