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>
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 12f0d62..de15d4e 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)
{
// Get number of points in each polygon
std::unique_ptr<sal_uInt16[]> pnPoints(new sal_uInt16[ nPoly ]);
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)
{
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()