Kaydet (Commit) 8ee49906 authored tarafından Armin Le Grand's avatar Armin Le Grand

Secured some places where PolyPolygons were created using a all-points count and a all-points array

üst 3c7cfb25
...@@ -336,8 +336,6 @@ sal_Bool EnhWMFReader::ReadEnhWMF() ...@@ -336,8 +336,6 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
case EMR_POLYPOLYLINE : case EMR_POLYPOLYLINE :
{ {
sal_uInt16* pnPoints;
sal_Int32 i, nPoly; sal_Int32 i, nPoly;
pWMF->SeekRel( 0x10 ); pWMF->SeekRel( 0x10 );
...@@ -349,9 +347,9 @@ sal_Bool EnhWMFReader::ReadEnhWMF() ...@@ -349,9 +347,9 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
{ {
if ( ( static_cast< sal_uInt32 >( nPoly ) * sizeof(sal_uInt16) ) <= ( nEndPos - pWMF->Tell() ) ) if ( ( static_cast< sal_uInt32 >( nPoly ) * sizeof(sal_uInt16) ) <= ( nEndPos - pWMF->Tell() ) )
{ {
pnPoints = new sal_uInt16[ nPoly ]; sal_uInt16* pnPoints = new sal_uInt16[ nPoly ];
for ( i = 0; i < nPoly; i++ ) for ( i = 0; i < nPoly && !pWMF->IsEof(); i++ )
{ {
*pWMF >> nPoints; *pWMF >> nPoints;
pnPoints[ i ] = (sal_uInt16)nPoints; pnPoints[ i ] = (sal_uInt16)nPoints;
...@@ -377,45 +375,55 @@ sal_Bool EnhWMFReader::ReadEnhWMF() ...@@ -377,45 +375,55 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
case EMR_POLYPOLYGON : case EMR_POLYPOLYGON :
{ {
sal_uInt16* pnPoints; sal_uInt32 nPoly(0);
Point* pPtAry; sal_uInt32 nGesPoints(0);
sal_uInt32 nReadPoints(0);
sal_uInt32 i, nPoly, nGesPoints;
pWMF->SeekRel( 0x10 ); pWMF->SeekRel( 0x10 );
// Anzahl der Polygone: // Anzahl der Polygone:
*pWMF >> nPoly >> nGesPoints; *pWMF >> nPoly >> nGesPoints;
if ( ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) ) if ( ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) && !pWMF->IsEof() )
{ {
if ( ( nPoly * sizeof(sal_uInt16) ) <= ( nEndPos - pWMF->Tell() ) ) if ( ( nPoly * sizeof(sal_uInt16) ) <= ( nEndPos - pWMF->Tell() ) )
{ {
pnPoints = new sal_uInt16[ nPoly ]; sal_uInt32 i(0);
sal_uInt16* pnPoints = new sal_uInt16[ nPoly ];
for ( i = 0; i < nPoly; i++ ) for ( i = 0; i < nPoly && !pWMF->IsEof(); i++ )
{ {
*pWMF >> nPoints; *pWMF >> nPoints;
pnPoints[ i ] = (sal_uInt16)nPoints; pnPoints[ i ] = (sal_uInt16)nPoints;
} }
if ( ( nGesPoints * (sizeof(sal_uInt32)+sizeof(sal_uInt32)) ) <= ( nEndPos - pWMF->Tell() ) ) if ( ( nGesPoints * (sizeof(sal_uInt32)+sizeof(sal_uInt32)) ) <= ( nEndPos - pWMF->Tell() ) && !pWMF->IsEof())
{ {
// Polygonpunkte holen: PolyPolygon aPolyPoly(nPoly, nPoly);
pPtAry = new Point[ nGesPoints ];
for ( i = 0; i < nGesPoints; i++ ) for ( i = 0; i < nPoly && !pWMF->IsEof(); i++ )
{
const sal_uInt16 nPointCount(pnPoints[i]);
Point* pPtAry = new Point[nPointCount];
for(sal_uInt16 j(0); j < nPointCount && !pWMF->IsEof(); j++)
{ {
*pWMF >> nX32 >> nY32; *pWMF >> nX32 >> nY32;
pPtAry[ i ] = Point( nX32, nY32 ); pPtAry[ j ] = Point( nX32, nY32 );
nReadPoints++;
} }
// PolyPolygon Actions erzeugen
PolyPolygon aPolyPoly( (sal_uInt16)nPoly, pnPoints, pPtAry ); aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
delete[] pPtAry; delete[] pPtAry;
} }
pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
}
delete[] pnPoints; delete[] pnPoints;
} }
} }
OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed from EMR_POLYPOLYGON is unequal imported number (!)");
} }
break; break;
...@@ -1204,41 +1212,55 @@ sal_Bool EnhWMFReader::ReadEnhWMF() ...@@ -1204,41 +1212,55 @@ sal_Bool EnhWMFReader::ReadEnhWMF()
case EMR_POLYPOLYGON16 : case EMR_POLYPOLYGON16 :
{ {
sal_uInt16* pnPoints; sal_uInt32 nPoly(0);
Point* pPtAry; sal_uInt32 nGesPoints(0);
sal_uInt32 i, nPoly, nGesPoints;
pWMF->SeekRel( 0x10 ); pWMF->SeekRel( 0x10 );
// Anzahl der Polygone: // Anzahl der Polygone:
*pWMF >> nPoly >> nGesPoints; *pWMF >> nPoly >> nGesPoints;
if ( ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) ) sal_uInt32 nReadPoints(0);
if ( ( nGesPoints < SAL_MAX_UINT32 / sizeof(Point) ) && ( nPoly < SAL_MAX_UINT32 / sizeof(sal_uInt16) ) && !pWMF->IsEof() )
{ {
if ( ( static_cast< sal_uInt32 >( nPoly ) * sizeof( sal_uInt16 ) ) <= ( nEndPos - pWMF->Tell() ) ) if ( ( static_cast< sal_uInt32 >( nPoly ) * sizeof( sal_uInt16 ) ) <= ( nEndPos - pWMF->Tell() ) )
{ {
pnPoints = new sal_uInt16[ nPoly ]; sal_uInt32 i(0);
for ( i = 0; i < nPoly; i++ ) sal_uInt16* pnPoints = new sal_uInt16[ nPoly ];
for ( i = 0; i < nPoly && !pWMF->IsEof(); i++ )
{ {
*pWMF >> nPoints; *pWMF >> nPoints;
pnPoints[ i ] = (sal_uInt16)nPoints; pnPoints[ i ] = (sal_uInt16)nPoints;
} }
if ( ( nGesPoints * (sizeof(sal_uInt16)+sizeof(sal_uInt16)) ) <= ( nEndPos - pWMF->Tell() ) )
if ( ( nGesPoints * (sizeof(sal_uInt16)+sizeof(sal_uInt16)) ) <= ( nEndPos - pWMF->Tell() ) && !pWMF->IsEof() )
{ {
// Polygonpunkte holen: PolyPolygon aPolyPoly(nPoly, nPoly);
pPtAry = new Point[ nGesPoints ];
for ( i = 0; i < nGesPoints; i++ ) for ( i = 0; i < nPoly && !pWMF->IsEof(); i++ )
{
const sal_uInt16 nPointCount(pnPoints[i]);
Point* pPtAry = new Point[nPointCount];
for(sal_uInt16 b(0); b < nPointCount && !pWMF->IsEof(); b++)
{ {
*pWMF >> nX16 >> nY16; *pWMF >> nX16 >> nY16;
pPtAry[ i ] = Point( nX16, nY16 ); pPtAry[b] = Point( nX16, nY16 );
nReadPoints++;
} }
// PolyPolygon Actions erzeugen aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
PolyPolygon aPolyPoly( (sal_uInt16)nPoly, pnPoints, pPtAry );
pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
delete[] pPtAry; delete[] pPtAry;
} }
// create PolyPolygon actions
pOut->DrawPolyPolygon( aPolyPoly, bRecordPath );
}
delete[] pnPoints; delete[] pnPoints;
} }
} }
OSL_ENSURE(nReadPoints == nGesPoints, "The number Points processed from EMR_POLYPOLYGON16 is unequal imported number (!)");
} }
break; break;
......
...@@ -330,28 +330,39 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc ) ...@@ -330,28 +330,39 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc )
case W_META_POLYPOLYGON: case W_META_POLYPOLYGON:
{ {
sal_uInt16 i, nPoly, nPoints; sal_uInt16 nPolyCount(0);
sal_uInt16* pnPoints;
Point* pPtAry; // get number of polygons
// Anzahl der Polygone: *pWMF >> nPolyCount;
*pWMF >> nPoly;
// Anzahl der Punkte eines jeden Polygons holen, Gesammtzahl der Punkte ermitteln: if(nPolyCount && !pWMF->IsEof())
pnPoints = new sal_uInt16[ nPoly ]; {
nPoints = 0; sal_uInt16* pnPoints = new sal_uInt16[nPolyCount];
for( i = 0; i < nPoly; i++ ) sal_uInt16 a(0);
PolyPolygon aPolyPoly(nPolyCount, nPolyCount);
for(a = 0; a < nPolyCount && !pWMF->IsEof(); a++)
{ {
*pWMF >> pnPoints[i]; *pWMF >> pnPoints[a];
nPoints = nPoints + pnPoints[i];
} }
// Polygonpunkte holen:
pPtAry = (Point*) new char[ nPoints * sizeof(Point) ]; for(a = 0; a < nPolyCount && !pWMF->IsEof(); a++)
for ( i = 0; i < nPoints; i++ ) {
pPtAry[ i ] = ReadPoint(); const sal_uInt16 nPointCount(pnPoints[a]);
// PolyPolygon Actions erzeugen Point* pPtAry = new Point[nPointCount];
PolyPolygon aPolyPoly( nPoly, pnPoints, pPtAry );
pOut->DrawPolyPolygon( aPolyPoly ); for(sal_uInt16 b(0); b < nPointCount && !pWMF->IsEof(); b++)
delete[] (char*) pPtAry; {
pPtAry[b] = ReadPoint();
}
aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
delete[] pPtAry;
}
delete[] pnPoints; delete[] pnPoints;
pOut->DrawPolyPolygon(aPolyPoly);
}
} }
break; break;
......
...@@ -261,8 +261,6 @@ public: ...@@ -261,8 +261,6 @@ public:
PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 ); PolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
PolyPolygon( const Polygon& rPoly ); PolyPolygon( const Polygon& rPoly );
PolyPolygon( sal_uInt16 nPoly, const sal_uInt16* pPointCountAry,
const Point* pPtAry );
PolyPolygon( const PolyPolygon& rPolyPoly ); PolyPolygon( const PolyPolygon& rPolyPoly );
~PolyPolygon(); ~PolyPolygon();
......
...@@ -123,25 +123,6 @@ PolyPolygon::PolyPolygon( const Polygon& rPoly ) ...@@ -123,25 +123,6 @@ PolyPolygon::PolyPolygon( const Polygon& rPoly )
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
PolyPolygon::PolyPolygon( sal_uInt16 nPoly, const sal_uInt16* pPointCountAry,
const Point* pPtAry )
{
DBG_CTOR( PolyPolygon, NULL );
if ( nPoly > MAX_POLYGONS )
nPoly = MAX_POLYGONS;
mpImplPolyPolygon = new ImplPolyPolygon( nPoly );
for ( sal_uInt16 i = 0; i < nPoly; i++ )
{
mpImplPolyPolygon->mpPolyAry[i] = new Polygon( *pPointCountAry, pPtAry );
pPtAry += *pPointCountAry;
pPointCountAry++;
}
}
// -----------------------------------------------------------------------
PolyPolygon::PolyPolygon( const PolyPolygon& rPolyPoly ) PolyPolygon::PolyPolygon( const PolyPolygon& rPolyPoly )
{ {
DBG_CTOR( PolyPolygon, NULL ); DBG_CTOR( PolyPolygon, NULL );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment