Author: alg
Date: Tue Aug 14 08:59:38 2012
New Revision: 1372787

URL: http://svn.apache.org/viewvc?rev=1372787&view=rev
Log:
Added adaption of binfilter for securing polygon creations

Modified:
    
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
    
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx

Modified: 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx?rev=1372787&r1=1372786&r2=1372787&view=diff
==============================================================================
--- 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
 (original)
+++ 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_enhwmf.cxx
 Tue Aug 14 08:59:38 2012
@@ -381,18 +381,26 @@ BOOL EnhWMFReader::ReadEnhWMF()
                                                *pWMF >> nPoints;
                                                pnPoints[ i ] = (UINT16)nPoints;
                                        }
-                                       // Polygonpunkte holen:
-                                       pPtAry  = (Point*) new char[ nGesPoints 
* sizeof(Point) ];
-       
-                                       for ( i = 0; i < nGesPoints; i++ )
-                                       {
-                                               *pWMF >> nX32 >> nY32;
-                                               pPtAry[ i ] = Point( nX32, nY32 
);
-                                       }
-                                       // PolyPolygon Actions erzeugen
-                                       PolyPolygon aPolyPoly( (UINT16)nPoly, 
pnPoints, pPtAry );
+
+                                       PolyPolygon aPolyPoly((UINT16)nPoly, 
(UINT16)nPoly);
+                    
+                    for ( i = 0; i < nPoly; i++ )
+                                       {
+                        const sal_uInt16 nPointCount(pnPoints[i]);
+                                       pPtAry = new Point[nPointCount];
+
+                        for(sal_uInt16 j(0); j < nPointCount; j++)
+                        {
+                                                   *pWMF >> nX32 >> nY32;
+                                                   pPtAry[j] = Point( nX32, 
nY32 );
+                        }
+
+                        aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
+                        delete[] pPtAry;
+                    }
+
+                    // PolyPolygon Actions erzeugen
                                        pOut->DrawPolyPolygon( aPolyPoly, 
bRecordPath );
-                                       delete[] (char*) pPtAry;
                                        delete[] pnPoints;
                                }
                        }
@@ -1116,18 +1124,26 @@ BOOL EnhWMFReader::ReadEnhWMF()
                                                *pWMF >> nPoints;
                                                pnPoints[ i ] = (UINT16)nPoints;
                                        }
-                                       // Polygonpunkte holen:
-                                       pPtAry  = (Point*) new char[ nGesPoints 
* sizeof(Point) ];
-                                       for ( i = 0; i < nGesPoints; i++ )
+                                       
+                                       PolyPolygon aPolyPoly((UINT16)nPoly, 
(UINT16)nPoly);
+
+                    for ( i = 0; i < nPoly; i++ )
                                        {
-                                               *pWMF >> nX16 >> nY16;
-                                               pPtAry[ i ] = Point( nX16, nY16 
);
-                                       }
+                        const sal_uInt16 nPointCount(pnPoints[i]);
+                                   pPtAry = new Point[nPointCount];
+
+                        for(sal_uInt16 j(0); j < nPointCount; j++)
+                        {
+                                                   *pWMF >> nX16 >> nY16;
+                                                   pPtAry[j] = Point( nX16, 
nY16 );
+                        }
+                
+                        aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
+                        delete[] pPtAry;
+                    }
        
                                        // PolyPolygon Actions erzeugen
-                                       PolyPolygon aPolyPoly( (UINT16)nPoly, 
pnPoints, pPtAry );
                                        pOut->DrawPolyPolygon( aPolyPoly, 
bRecordPath );
-                                       delete[] (char*) pPtAry;
                                        delete[] pnPoints;
                                }
                        }

Modified: 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx
URL: 
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx?rev=1372787&r1=1372786&r2=1372787&view=diff
==============================================================================
--- 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx
 (original)
+++ 
incubator/ooo/trunk/main/binfilter/bf_svtools/source/filter.vcl/wmf/svt_winwmf.cxx
 Tue Aug 14 08:59:38 2012
@@ -346,14 +346,25 @@ void WMFReader::ReadRecordParams( USHORT
                                *pWMF >> pnPoints[i];
                                nPoints = nPoints + pnPoints[i];
                        }
-                       // Polygonpunkte holen:
-                       pPtAry  = (Point*) new char[ nPoints * sizeof(Point) ];
-                       for ( i = 0; i < nPoints; i++ )
-                               pPtAry[ i ] = ReadPoint();
+
+                       PolyPolygon aPolyPoly(nPoly, nPoly);
+
+            for( i = 0; i < nPoly; i++ )
+                       {
+                const sal_uInt16 nPointCount(pnPoints[i]);
+                           pPtAry = new Point[nPointCount];
+
+                for(sal_uInt16 j(0); j < nPointCount; j++)
+                {
+                               pPtAry[j] = ReadPoint();
+                }
+                
+                aPolyPoly.Insert(Polygon(nPointCount, pPtAry));
+                delete[] pPtAry;
+            }
+
                        // PolyPolygon Actions erzeugen
-                       PolyPolygon aPolyPoly( nPoly, pnPoints, pPtAry );
                        pOut->DrawPolyPolygon( aPolyPoly );
-                       delete[] (char*) pPtAry;
                        delete[] pnPoints;
                }
                break;


Reply via email to