[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source

Caolán McNamara caolanm at redhat.com
Sun Jun 18 13:07:26 UTC 2017


 sw/source/core/edit/edfcol.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 5dadc59dd1f9b4ff27221e231a5f37d31e9a41f5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri May 26 10:39:47 2017 +0100

    coverity#1409893 Division or modulo by float zero
    
    Change-Id: I697e9c7772792b02257ed1f40666dd70bb70300c
    Reviewed-on: https://gerrit.libreoffice.org/38914
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index c2cf6252dec0..b44cdf43a115 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -425,8 +425,12 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& rWatermark)
             OutputDevice* pOut = Application::GetDefaultDevice();
             vcl::Font aFont(pOut->GetFont());
             aFont.SetFamilyName(sFont);
-            fRatio = aFont.GetFontSize().Height();
-            fRatio /= pOut->GetTextWidth(rWatermark.GetText());
+            auto nTextWidth = pOut->GetTextWidth(rWatermark.GetText());
+            if (nTextWidth)
+            {
+                fRatio = aFont.GetFontSize().Height();
+                fRatio /= nTextWidth;
+            }
 
             // Calc the size.
             sal_Int32 nWidth = 0;


More information about the Libreoffice-commits mailing list