[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - emfio/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 8 08:43:35 UTC 2021


 emfio/source/reader/mtftools.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit 3d1e59d9882d1146be303dafff937a51ba4e1867
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 25 15:06:50 2021 +0000
Commit:     Michael Stahl <michael.stahl at allotropia.de>
CommitDate: Thu Jul 8 10:42:56 2021 +0200

    ofz#31370 Divide-by-zero
    
    Change-Id: If581d61b678616f8a80f8ad2d2dea5ecbf10d8fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111557
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit da457f41f8f0a14014ff9f122467f3a26eb1ac20)
    
    and...
    
    cid#1473321 Division or modulo by float zero
    
    and
    
    cid#1473322 Division or modulo by float zero
    
    where oss-fuzz also found a reproducer as ofz#31370 Divide-by-zero
    
    Change-Id: I0facd2e794384515891dbf040f4fe43530478d3d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111601
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 28e022c258682dc030668fed7879d9d3f078b720)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118595
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>

diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index 0d918af72dc0..53564c34f82b 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -385,10 +385,13 @@ namespace emfio
             // calculate measured TextLength
             const vcl::Font& rFontCandidate(maCurrentMetaFontAction->GetFont());
             pTempVirtualDevice->SetFont(rFontCandidate);
-            const tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText));
+            tools::Long nMeasuredTextLength(pTempVirtualDevice->GetTextWidth(rText));
+            // on failure, use original length
+            if (!nMeasuredTextLength)
+                nMeasuredTextLength = nImportedTextLength;
 
             // compare expected and imported TextLengths
-            if(nImportedTextLength != nMeasuredTextLength)
+            if (nImportedTextLength != nMeasuredTextLength)
             {
                 const double fFactorText(static_cast<double>(nImportedTextLength) / static_cast<double>(nMeasuredTextLength));
                 const double fFactorTextPercent(fabs(1.0 - fFactorText) * 100.0);
@@ -417,6 +420,9 @@ namespace emfio
                     rFontCandidate2.SetAverageFontWidth(static_cast<tools::Long>(fCorrectedAverageFontWidth));
                     pTempVirtualDevice->SetFont(rFontCandidate2);
                     nCorrectedTextLength = pTempVirtualDevice->GetTextWidth(rText);
+                    // on failure, use original length
+                    if (!nCorrectedTextLength)
+                        nCorrectedTextLength = nImportedTextLength;
                 }
 
                 const double fFactorCorrectedText(static_cast<double>(nImportedTextLength) / static_cast<double>(nCorrectedTextLength));


More information about the Libreoffice-commits mailing list