diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-06-15 11:24:47 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-06-15 13:58:56 +0200 |
commit | 5c6c297f50988308d80060a2d0e89ec0601768dc (patch) | |
tree | 74a1c15f520502e24f0a9ddfbe94f4925327ee80 | |
parent | 36b45cc585fe914751848a1b8febf3ba0a41761b (diff) |
oox: fix div by zero in lclCalculateCropPercentage()
Similar to what oox::vml::ShapeType::getAbsRectangle() already does.
Crashreport signature:
Fatal signal received: SIGFPE code: 1 for address: 0x7fcd55eeff59
program/libooxlo.so
oox::drawingml::GraphicProperties::pushToPropMap(oox::PropertyMap&, oox::GraphicHelper const&, bool, bool) const
oox/source/drawingml/fillproperties.cxx:103
Change-Id: I0f82cbc955d9e60bad103682638b07153a5589e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135869
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 21c7d84d1309..f10be4556610 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -98,7 +98,15 @@ void lclCalculateCropPercentage(uno::Reference<graphic::XGraphic> const & xGraph sal_Int32 nScaledHeight = aBitmapEx.GetSizePixel().Height(); sal_Int32 nOrigWidth = (nScaledWidth * (100000 - aFillRect.X1 - aFillRect.X2)) / 100000; + if (nOrigWidth == 0) + { + nOrigWidth = 1; + } sal_Int32 nOrigHeight = (nScaledHeight * (100000 - aFillRect.Y1 - aFillRect.Y2)) / 100000; + if (nOrigHeight == 0) + { + nOrigHeight = 1; + } sal_Int32 nLeftPercentage = nScaledWidth * aFillRect.X1 / nOrigWidth; sal_Int32 nRightPercentage = nScaledWidth * aFillRect.X2 / nOrigWidth; |