[Libreoffice-commits] core.git: 2 commits - filter/source tools/source

Caolán McNamara caolanm at redhat.com
Fri Oct 27 07:56:25 UTC 2017


 filter/source/msfilter/svdfppt.cxx |   49 ++++++++++++++++---------------------
 tools/source/generic/poly.cxx      |    9 ++++--
 2 files changed, 28 insertions(+), 30 deletions(-)

New commits:
commit 85b698cbd3de7ffd3c69309d452c1bf93156b75c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 26 09:20:56 2017 +0100

    ofz#3812 Divide-by-zero
    
    Change-Id: I1a278302b995137d3e73620c003534498a59ba14
    Reviewed-on: https://gerrit.libreoffice.org/43870
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 7564e9f50125..e7b9397ab734 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1687,11 +1687,14 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
 
             // calculate common direction vector, normalize
             const basegfx::B2DVector aDirection(aNext + aPrev);
+            const double fDirectionLen = aDirection.getLength();
+            if (fDirectionLen == 0.0)
+                return;
 
-            if(PolyFlags::Smooth == nCFlag)
+            if (PolyFlags::Smooth == nCFlag)
             {
                 // C1: apply common direction vector, preserve individual lengths
-                const double fInvDirectionLen(1.0 / aDirection.getLength());
+                const double fInvDirectionLen(1.0 / fDirectionLen);
                 roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint + (aDirection * (aNext.getLength() * fInvDirectionLen))));
                 roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint - (aDirection * (aPrev.getLength() * fInvDirectionLen))));
             }
@@ -1699,7 +1702,7 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
             {
                 // C2: get mediated length. Taking half of the unnormalized direction would be
                 // an approximation, but not correct.
-                const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / aDirection.getLength()));
+                const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / fDirectionLen));
                 const basegfx::B2DVector aScaledDirection(aDirection * fMedLength);
 
                 // Bring Direction to correct length and apply
commit 3fc4211a0f25543a947f1d47153f7c0a0be01a4c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Oct 26 09:13:03 2017 +0100

    ofz#3811 Integer-overflow
    
    Change-Id: Ia08ac1ae46d4af6df7b0a590752e17a6d9a6836e
    Reviewed-on: https://gerrit.libreoffice.org/43869
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 5e6cfcca21a0..9d9b08b5b88f 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6703,35 +6703,30 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
                                         sal_uInt32 nCharIdx = pSpecInfo->nCharIdx;
 
                                         // portions and text have to been splitted in some cases
-                                        for ( ; nI < aStyleTextPropReader.aCharPropList.size(); )
+                                        for ( ; nI < aStyleTextPropReader.aCharPropList.size(); ++nI)
                                         {
-                                            PPTCharPropSet* pSet = aStyleTextPropReader.aCharPropList[ nI ];
-                                            if ( pSet->mnOriginalTextPos < nCharIdx )
-                                            {
-                                                pSet->mnLanguage[ 0 ] = pSpecInfo->nLanguage[ 0 ];
-                                                pSet->mnLanguage[ 1 ] = pSpecInfo->nLanguage[ 1 ];
-                                                pSet->mnLanguage[ 2 ] = pSpecInfo->nLanguage[ 2 ];
-                                                // test if the current portion needs to be splitted
-                                                if ( pSet->maString.getLength() > 1 )
-                                                {
-                                                    sal_Int32 nIndexOfNextPortion = pSet->maString.getLength() + pSet->mnOriginalTextPos;
-                                                    sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx;
-                                                    sal_Int32 nOldLen = pSet->maString.getLength() - nNewLen;
-
-                                                    if ( ( nNewLen > 0 ) && ( nOldLen > 0 ) )
-                                                    {
-                                                        OUString aString( pSet->maString );
-                                                        PPTCharPropSet* pNew = new PPTCharPropSet( *pSet );
-                                                        pSet->maString = aString.copy( 0, nOldLen);
-                                                        pNew->maString = aString.copy( nOldLen, nNewLen);
-                                                        pNew->mnOriginalTextPos += nOldLen;
-                                                        aStyleTextPropReader.aCharPropList.insert( aStyleTextPropReader.aCharPropList.begin() + nI + 1, pNew );
-                                                    }
-                                                }
-                                            }
-                                            else
+                                            PPTCharPropSet* pSet = aStyleTextPropReader.aCharPropList[nI];
+                                            if (pSet->mnOriginalTextPos >= nCharIdx)
                                                 break;
-                                            nI++;
+                                            pSet->mnLanguage[0] = pSpecInfo->nLanguage[0];
+                                            pSet->mnLanguage[1] = pSpecInfo->nLanguage[1];
+                                            pSet->mnLanguage[2] = pSpecInfo->nLanguage[2];
+                                            // test if the current portion needs to be splitted
+                                            if (pSet->maString.getLength() <= 1)
+                                                continue;
+                                            sal_Int32 nIndexOfNextPortion = pSet->maString.getLength() + pSet->mnOriginalTextPos;
+                                            sal_Int32 nNewLen = nIndexOfNextPortion - nCharIdx;
+                                            if (nNewLen <= 0)
+                                                continue;
+                                            sal_Int32 nOldLen = pSet->maString.getLength() - nNewLen;
+                                            if (nOldLen <= 0)
+                                                continue;
+                                            OUString aString(pSet->maString);
+                                            PPTCharPropSet* pNew = new PPTCharPropSet(*pSet);
+                                            pSet->maString = aString.copy(0, nOldLen);
+                                            pNew->maString = aString.copy(nOldLen, nNewLen);
+                                            pNew->mnOriginalTextPos += nOldLen;
+                                            aStyleTextPropReader.aCharPropList.insert(aStyleTextPropReader.aCharPropList.begin() + nI + 1, pNew);
                                         }
                                     }
                                 }


More information about the Libreoffice-commits mailing list