vcl/source/filter/wmf/enhwmf.cxx |   61 ++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 29 deletions(-)

New commits:
commit 12ed6ad7a0efb55c9b527e6193080426fb8e64f9
Author: Caolán McNamara <caol...@redhat.com>
Date:   Sat Apr 8 21:46:40 2017 +0100

    make this more readable
    
    no logic change intended
    
    Change-Id: I097247ab1da409e56dce01fdb000e8d416e82add
    Reviewed-on: https://gerrit.libreoffice.org/36306
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 12f0d6232ff5..de15d4e6ed7c 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -592,44 +592,47 @@ void EnhWMFReader::ReadAndDrawPolyPolygon()
     pWMF->ReadUInt32( nPoly ).ReadUInt32( nGesPoints );
     if (pWMF->Tell() >= nEndPos)
         return;
-    if ( pWMF->good() &&
-        ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && //check against 
numeric overflowing
-        ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) &&
-        ( (  nPoly * sizeof( sal_uInt16 ) ) <= ( nEndPos - pWMF->Tell() ) ))
+    if (!pWMF->good())
+        return;
+    //check against numeric overflowing
+    if (nGesPoints >= SAL_MAX_UINT32 / sizeof(Point))
+        return;
+    if (nPoly >= SAL_MAX_UINT32 / sizeof(sal_uInt16))
+        return;
+    if (nPoly * sizeof(sal_uInt16) > nEndPos - pWMF->Tell())
+        return;
+
+    // Get number of points in each polygon
+    std::unique_ptr<sal_uInt16[]> pnPoints(new sal_uInt16[ nPoly ]);
+    for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i)
+    {
+        sal_uInt32 nPoints(0);
+        pWMF->ReadUInt32( nPoints );
+        pnPoints[ i ] = (sal_uInt16)nPoints;
+    }
+    if ( pWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( nEndPos - 
pWMF->Tell() ) )
     {
-        // Get number of points in each polygon
-        std::unique_ptr<sal_uInt16[]> pnPoints(new sal_uInt16[ nPoly ]);
+        // Get polygon points
+        tools::PolyPolygon aPolyPoly(nPoly, nPoly);
         for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i)
         {
-            sal_uInt32 nPoints(0);
-            pWMF->ReadUInt32( nPoints );
-            pnPoints[ i ] = (sal_uInt16)nPoints;
-        }
-        if ( pWMF->good() && ( nGesPoints * (sizeof(T)+sizeof(T)) ) <= ( 
nEndPos - pWMF->Tell() ) )
-        {
-            // Get polygon points
-            tools::PolyPolygon aPolyPoly(nPoly, nPoly);
-            for (sal_uInt32 i = 0; i < nPoly && pWMF->good(); ++i)
+            const sal_uInt16 nPointCount(pnPoints[i]);
+            std::unique_ptr<Point[]> pPtAry(new Point[nPointCount]);
+            for (sal_uInt16 j = 0; j < nPointCount && pWMF->good(); ++j)
             {
-                const sal_uInt16 nPointCount(pnPoints[i]);
-                std::unique_ptr<Point[]> pPtAry(new Point[nPointCount]);
-                for (sal_uInt16 j = 0; j < nPointCount && pWMF->good(); ++j)
-                {
-                    T nX(0), nY(0);
-                    *pWMF >> nX >> nY;
-                    pPtAry[ j ] = Point( nX, nY );
-                    ++nReadPoints;
-                }
-
-                aPolyPoly.Insert( tools::Polygon(nPointCount, pPtAry.get()) );
+                T nX(0), nY(0);
+                *pWMF >> nX >> nY;
+                pPtAry[ j ] = Point( nX, nY );
+                ++nReadPoints;
             }
 
-            pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
+            aPolyPoly.Insert( tools::Polygon(nPointCount, pPtAry.get()) );
         }
 
-        OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed 
from EMR_POLYPOLYGON is unequal imported number (!)");
-
+        pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
     }
+
+    OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed from 
EMR_POLYPOLYGON is unequal imported number (!)");
 }
 
 bool EnhWMFReader::ReadEnhWMF()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to