summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-24 19:55:33 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-25 12:02:29 +0200
commitdbb2bdb4ad84cb3947e142daae991f869640b7b6 (patch)
tree0f757a20e97555fa306d671078287b19cc9f016f
parentce5d609da9d20b3c91f6f8eb4ee88451cbd55a9d (diff)
ofz#47587 Timeout
Change-Id: Ic2e168020ad9040705fbdcd0b6945c6a2d2f5b8f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134884 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/outdev/hatch.cxx65
1 files changed, 37 insertions, 28 deletions
diff --git a/vcl/source/outdev/hatch.cxx b/vcl/source/outdev/hatch.cxx
index 39c4e124ad38..9ae44a563c1b 100644
--- a/vcl/source/outdev/hatch.cxx
+++ b/vcl/source/outdev/hatch.cxx
@@ -120,6 +120,35 @@ void OutputDevice::AddHatchActions( const tools::PolyPolygon& rPolyPoly, const H
}
}
+static bool HasSaneNSteps(const Point& rPt1, const Point& rEndPt1, const Size& rInc)
+{
+ tools::Long nVertSteps = -1;
+ if (rInc.Height())
+ {
+ bool bFail = o3tl::checked_sub(rEndPt1.Y(), rPt1.Y(), nVertSteps);
+ if (bFail)
+ nVertSteps = std::numeric_limits<tools::Long>::max();
+ else
+ nVertSteps = nVertSteps / rInc.Height();
+ }
+ tools::Long nHorzSteps = -1;
+ if (rInc.Width())
+ {
+ bool bFail = o3tl::checked_sub(rEndPt1.X(), rPt1.X(), nHorzSteps);
+ if (bFail)
+ nHorzSteps = std::numeric_limits<tools::Long>::max();
+ else
+ nHorzSteps = nHorzSteps / rInc.Width();
+ }
+ auto nSteps = std::max(nVertSteps, nHorzSteps);
+ if (nSteps > 1024)
+ {
+ SAL_WARN("vcl.gdi", "skipping slow hatch with " << nSteps << " steps");
+ return false;
+ }
+ return true;
+}
+
void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch, bool bMtf )
{
assert(!is_double_buffered_window());
@@ -158,39 +187,13 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
// Single hatch
aRect.AdjustLeft( -nLogPixelWidth ); aRect.AdjustTop( -nLogPixelWidth ); aRect.AdjustRight(nLogPixelWidth ); aRect.AdjustBottom(nLogPixelWidth );
CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 );
+ if (utl::ConfigManager::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc))
+ return;
if (aInc.Width() <= 0 && aInc.Height() <= 0)
SAL_WARN("vcl.gdi", "invalid increment");
else
{
- if (utl::ConfigManager::IsFuzzing())
- {
- tools::Long nVertSteps = -1;
- if (aInc.Height())
- {
- bool bFail = o3tl::checked_sub(aEndPt1.Y(), aPt1.Y(), nVertSteps);
- if (bFail)
- nVertSteps = std::numeric_limits<tools::Long>::max();
- else
- nVertSteps = nVertSteps / aInc.Height();
- }
- tools::Long nHorzSteps = -1;
- if (aInc.Width())
- {
- bool bFail = o3tl::checked_sub(aEndPt1.X(), aPt1.X(), nHorzSteps);
- if (bFail)
- nHorzSteps = std::numeric_limits<tools::Long>::max();
- else
- nHorzSteps = nHorzSteps / aInc.Width();
- }
- auto nSteps = std::max(nVertSteps, nHorzSteps);
- if (nSteps > 1024)
- {
- SAL_WARN("vcl.gdi", "skipping slow hatch with " << nSteps << " steps");
- return;
- }
- }
-
do
{
DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
@@ -204,6 +207,9 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
{
// Double hatch
CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900_deg10, aPt1, aPt2, aInc, aEndPt1 );
+ if (utl::ConfigManager::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc))
+ return;
+
do
{
DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
@@ -216,6 +222,9 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
{
// Triple hatch
CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450_deg10, aPt1, aPt2, aInc, aEndPt1 );
+ if (utl::ConfigManager::IsFuzzing() && !HasSaneNSteps(aPt1, aEndPt1, aInc))
+ return;
+
do
{
DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );