oox/source/drawingml/fillproperties.cxx |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 2859ec288f2c1323ea3123d82cb1684b349ff598
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Wed Jun 15 15:52:18 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jun 15 20:14:35 2022 +0200

    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/+/135910
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/oox/source/drawingml/fillproperties.cxx 
b/oox/source/drawingml/fillproperties.cxx
index 98b9e2f93e73..7d6c41a81fc6 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -99,7 +99,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;

Reply via email to