tools/source/generic/poly.cxx |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 841788923ce185c140ebeac6d34faffa348c8b6e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Mar 13 11:23:07 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Mar 13 14:51:53 2022 +0100

    ofz#45527 detect too many points earlier
    
    Change-Id: I7716ca8b9de9312bcaabf1d16e60dbac7ae87e52
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131492
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index b3f53cb0e673..687cb6a5d4fb 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1156,7 +1156,8 @@ static void ImplAdaptiveSubdivide( std::vector<Point>& 
rPoints,
     // stop if distance from line is guaranteed to be bounded by d
     if( old_d2 > d2 &&
         recursionDepth < maxRecursionDepth &&
-        distance2 >= d2 )
+        distance2 >= d2 &&
+        rPoints.size() < SAL_MAX_UINT16 )
     {
         // deCasteljau bezier arc, split at t=0.5
         // Foley/vanDam, p. 508
commit f7151c8ab4e4928de8f29c2b4ac232b0a7cefa74
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Mar 13 11:19:55 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Mar 13 14:51:40 2022 +0100

    pass reference to the target vector instead
    
    no logic change intended here
    
    Change-Id: I680914a6a41cceab41f68456e98de5f3b4a8a639
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131491
    Tested-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index ed0086a9df37..b3f53cb0e673 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1106,8 +1106,8 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
 
 /** Recursively subdivide cubic bezier curve via deCasteljau.
 
-   @param rPointIter
-   Output iterator, where the subdivided polylines are written to.
+   @param rPoints
+   Output vector, where the subdivided polylines are written to.
 
    @param d
    Squared difference of curve to a straight line
@@ -1120,7 +1120,7 @@ void Polygon::Optimize( PolyOptimizeFlags nOptimizeFlags )
    curve does not deviate more than one pixel from a straight line.
 
 */
-static void ImplAdaptiveSubdivide( ::std::back_insert_iterator< ::std::vector< 
Point > >& rPointIter,
+static void ImplAdaptiveSubdivide( std::vector<Point>& rPoints,
                                    const double old_d2,
                                    int recursionDepth,
                                    const double d2,
@@ -1172,15 +1172,15 @@ static void ImplAdaptiveSubdivide( 
::std::back_insert_iterator< ::std::vector< P
 
         // subdivide further
         ++recursionDepth;
-        ImplAdaptiveSubdivide(rPointIter, distance2, recursionDepth, d2, L1x, 
L1y, L2x, L2y, L3x, L3y, L4x, L4y);
-        ImplAdaptiveSubdivide(rPointIter, distance2, recursionDepth, d2, R1x, 
R1y, R2x, R2y, R3x, R3y, R4x, R4y);
+        ImplAdaptiveSubdivide(rPoints, distance2, recursionDepth, d2, L1x, 
L1y, L2x, L2y, L3x, L3y, L4x, L4y);
+        ImplAdaptiveSubdivide(rPoints, distance2, recursionDepth, d2, R1x, 
R1y, R2x, R2y, R3x, R3y, R4x, R4y);
     }
     else
     {
         // requested resolution reached.
         // Add end points to output iterator.
         // order is preserved, since this is so to say depth first traversal.
-        *rPointIter++ = Point( FRound(P1x), FRound(P1y) );
+        rPoints.push_back(Point(FRound(P1x), FRound(P1y)));
     }
 }
 
@@ -1196,7 +1196,6 @@ void Polygon::AdaptiveSubdivide( Polygon& rResult, const 
double d ) const
         sal_uInt16 nPts( GetSize() );
         ::std::vector< Point > aPoints;
         aPoints.reserve( nPts );
-        ::std::back_insert_iterator< ::std::vector< Point > > aPointIter( 
aPoints );
 
         for(i=0; i<nPts;)
         {
@@ -1210,7 +1209,7 @@ void Polygon::AdaptiveSubdivide( Polygon& rResult, const 
double d ) const
                     ( PolyFlags::Control == mpImplPolygon->mxFlagAry[ i + 2 ] 
) &&
                     ( PolyFlags::Normal == P4 || PolyFlags::Smooth == P4 || 
PolyFlags::Symmetric == P4 ) )
                 {
-                    ImplAdaptiveSubdivide( aPointIter, d*d+1.0, 0, d*d,
+                    ImplAdaptiveSubdivide( aPoints, d*d+1.0, 0, d*d,
                                            mpImplPolygon->mxPointAry[ i ].X(), 
  mpImplPolygon->mxPointAry[ i ].Y(),
                                            mpImplPolygon->mxPointAry[ i+1 
].X(), mpImplPolygon->mxPointAry[ i+1 ].Y(),
                                            mpImplPolygon->mxPointAry[ i+2 
].X(), mpImplPolygon->mxPointAry[ i+2 ].Y(),
@@ -1220,7 +1219,7 @@ void Polygon::AdaptiveSubdivide( Polygon& rResult, const 
double d ) const
                 }
             }
 
-            *aPointIter++ = mpImplPolygon->mxPointAry[ i++ ];
+            aPoints.push_back(mpImplPolygon->mxPointAry[i++]);
 
             if (aPoints.size() >= SAL_MAX_UINT16)
             {

Reply via email to