diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-07-17 15:26:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-07-17 17:23:44 +0200 |
commit | 8ab54ac42ca2516c333a49fb23f6d27196122c22 (patch) | |
tree | 9b69dd8a498e2ec93663045d281562828a3d2ab9 | |
parent | 604583b177fbf8fa5044e54d0a35b9adff949e45 (diff) |
ofz#48585 Out-of-memory
Change-Id: If6bb603cc78863df88d5630b4bd5b1198b4050de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137148
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | basegfx/source/curve/b2dcubicbezier.cxx | 4 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolygontools.cxx | 4 | ||||
-rw-r--r-- | basegfx/source/polygon/b2dpolypolygontools.cxx | 4 | ||||
-rw-r--r-- | include/basegfx/curve/b2dcubicbezier.hxx | 5 | ||||
-rw-r--r-- | include/basegfx/polygon/b2dpolygontools.hxx | 2 | ||||
-rw-r--r-- | include/basegfx/polygon/b2dpolypolygontools.hxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/line.cxx | 4 |
7 files changed, 15 insertions, 10 deletions
diff --git a/basegfx/source/curve/b2dcubicbezier.cxx b/basegfx/source/curve/b2dcubicbezier.cxx index 6528e1492a32..d33cd82b194d 100644 --- a/basegfx/source/curve/b2dcubicbezier.cxx +++ b/basegfx/source/curve/b2dcubicbezier.cxx @@ -610,12 +610,12 @@ namespace basegfx } // adaptive subdivide by distance - void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound) const + void B2DCubicBezier::adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound, int nRecurseLimit) const { if(isBezier()) { ImpSubDivDistance(maStartPoint, maControlPointA, maControlPointB, maEndPoint, rTarget, - fDistanceBound * fDistanceBound, std::numeric_limits<double>::max(), 30); + fDistanceBound * fDistanceBound, std::numeric_limits<double>::max(), nRecurseLimit); } else { diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx index 4b8550546e5c..03f5299ca505 100644 --- a/basegfx/source/polygon/b2dpolygontools.cxx +++ b/basegfx/source/polygon/b2dpolygontools.cxx @@ -157,7 +157,7 @@ namespace basegfx::utils return rCandidate.getContinuityInPoint(nIndex); } - B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound) + B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound, int nRecurseLimit) { if(rCandidate.areControlPointsUsed()) { @@ -213,7 +213,7 @@ namespace basegfx::utils } // call adaptive subdivide which adds edges to aRetval accordingly - aBezier.adaptiveSubdivideByDistance(aRetval, fBound); + aBezier.adaptiveSubdivideByDistance(aRetval, fBound, nRecurseLimit); } else { diff --git a/basegfx/source/polygon/b2dpolypolygontools.cxx b/basegfx/source/polygon/b2dpolypolygontools.cxx index 3f8f51c52404..faf734f6e79e 100644 --- a/basegfx/source/polygon/b2dpolypolygontools.cxx +++ b/basegfx/source/polygon/b2dpolypolygontools.cxx @@ -113,7 +113,7 @@ namespace basegfx::utils return rCandidate; } - B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound) + B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound, int nRecurseLimit) { if(rCandidate.areControlPointsUsed()) { @@ -123,7 +123,7 @@ namespace basegfx::utils { if(rPolygon.areControlPointsUsed()) { - aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound)); + aRetval.append(utils::adaptiveSubdivideByDistance(rPolygon, fDistanceBound, nRecurseLimit)); } else { diff --git a/include/basegfx/curve/b2dcubicbezier.hxx b/include/basegfx/curve/b2dcubicbezier.hxx index 4d8d9406e930..fe81ed523d97 100644 --- a/include/basegfx/curve/b2dcubicbezier.hxx +++ b/include/basegfx/curve/b2dcubicbezier.hxx @@ -143,8 +143,11 @@ namespace basegfx @param fDistanceBound Bound on the maximal distance of the approximation to the true curve. + + @param nRecurseLimit + Bound on recursion for the bezier case. */ - void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound) const; + void adaptiveSubdivideByDistance(B2DPolygon& rTarget, double fDistanceBound, int nRecurseLimit = 30) const; // get point at given relative position B2DPoint interpolatePoint(double t) const; diff --git a/include/basegfx/polygon/b2dpolygontools.hxx b/include/basegfx/polygon/b2dpolygontools.hxx index 8f3ef342f3bc..d5aa092ed9cb 100644 --- a/include/basegfx/polygon/b2dpolygontools.hxx +++ b/include/basegfx/polygon/b2dpolygontools.hxx @@ -135,7 +135,7 @@ namespace basegfx::utils BASEGFX_DLLPUBLIC B2VectorContinuity getContinuityInPoint(const B2DPolygon& rCandidate, sal_uInt32 nIndex); // Subdivide all contained curves. Use distanceBound value if given. - BASEGFX_DLLPUBLIC B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound); + BASEGFX_DLLPUBLIC B2DPolygon adaptiveSubdivideByDistance(const B2DPolygon& rCandidate, double fDistanceBound, int nRecurseLimit = 30); // Subdivide all contained curves. Use angleBound value if given. BASEGFX_DLLPUBLIC B2DPolygon adaptiveSubdivideByAngle(const B2DPolygon& rCandidate, double fAngleBound = 0.0); diff --git a/include/basegfx/polygon/b2dpolypolygontools.hxx b/include/basegfx/polygon/b2dpolypolygontools.hxx index d253531f6ac9..896094633230 100644 --- a/include/basegfx/polygon/b2dpolypolygontools.hxx +++ b/include/basegfx/polygon/b2dpolypolygontools.hxx @@ -49,7 +49,7 @@ namespace basegfx::utils BASEGFX_DLLPUBLIC B2DPolyPolygon correctOutmostPolygon(const B2DPolyPolygon& rCandidate); // Subdivide all contained curves. Use distanceBound value if given. - BASEGFX_DLLPUBLIC B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound); + BASEGFX_DLLPUBLIC B2DPolyPolygon adaptiveSubdivideByDistance(const B2DPolyPolygon& rCandidate, double fDistanceBound, int nRecurseLimit = 30); // Subdivide all contained curves. Use distanceBound value if given. Else, a convenient one // is created. diff --git a/vcl/source/outdev/line.cxx b/vcl/source/outdev/line.cxx index 2556a09bff82..305484792736 100644 --- a/vcl/source/outdev/line.cxx +++ b/vcl/source/outdev/line.cxx @@ -22,6 +22,7 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dlinegeometry.hxx> #include <tools/debug.hxx> +#include <unotools/configmgr.hxx> #include <vcl/lineinfo.hxx> #include <vcl/metaact.hxx> @@ -264,7 +265,8 @@ void OutputDevice::drawLine( basegfx::B2DPolyPolygon aLinePolyPolygon, const Lin // but one that is at least as good as ImplSubdivideBezier was. // There, Polygon::AdaptiveSubdivide was used with default parameter // 1.0 as quality index. - aLinePolyPolygon = basegfx::utils::adaptiveSubdivideByDistance(aLinePolyPolygon, 1.0); + static int nRecurseLimit = utl::ConfigManager::IsFuzzing() ? 15 : 30; + aLinePolyPolygon = basegfx::utils::adaptiveSubdivideByDistance(aLinePolyPolygon, 1.0, nRecurseLimit); } for(auto const& rPolygon : std::as_const(aLinePolyPolygon)) |