diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-04-08 21:46:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-04-09 18:33:39 +0200 |
commit | 12ed6ad7a0efb55c9b527e6193080426fb8e64f9 (patch) | |
tree | 816064dffa19d6c7e21c715a4ac500875589763a /vcl/source/filter/wmf | |
parent | 886d76e50eab863a38010b983214e2ecaca658cf (diff) |
make this more readable
no logic change intended
Change-Id: I097247ab1da409e56dce01fdb000e8d416e82add
Reviewed-on: https://gerrit.libreoffice.org/36306
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/filter/wmf')
-rw-r--r-- | vcl/source/filter/wmf/enhwmf.cxx | 61 |
1 files changed, 32 insertions, 29 deletions
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() |