vcl/source/filter/idxf/dxf2mtf.cxx  |    5 ++---
 vcl/source/filter/idxf/dxfentrd.cxx |   18 ++++++++++--------
 vcl/source/filter/idxf/dxfentrd.hxx |    2 +-
 3 files changed, 13 insertions(+), 12 deletions(-)

New commits:
commit 2cb23f6ff94a7ad466cd035df2f6519a7dbd0b57
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Apr 26 10:47:45 2022 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Apr 26 13:58:11 2022 +0200

    ofz#47029 Timeout
    
    Change-Id: I0fe3a01b237eb142b9e156fc886144f48f8ede18
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133436
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/filter/idxf/dxf2mtf.cxx 
b/vcl/source/filter/idxf/dxf2mtf.cxx
index c0105f4bc6da..2b26abffd38e 100644
--- a/vcl/source/filter/idxf/dxf2mtf.cxx
+++ b/vcl/source/filter/idxf/dxf2mtf.cxx
@@ -573,15 +573,14 @@ void DXF2GDIMetaFile::DrawLWPolyLineEntity(const 
DXFLWPolyLineEntity & rE, const
 
 void DXF2GDIMetaFile::DrawHatchEntity(const DXFHatchEntity & rE, const 
DXFTransform & rTransform )
 {
-    if ( !rE.nBoundaryPathCount )
+    if (rE.aBoundaryPathData.empty())
         return;
 
     SetAreaAttribute( rE );
     tools::PolyPolygon aPolyPoly;
-    for (sal_Int32 j = 0; j < rE.nBoundaryPathCount; ++j)
+    for (const DXFBoundaryPathData& rPathData : rE.aBoundaryPathData)
     {
         std::vector< Point > aPtAry;
-        const DXFBoundaryPathData& rPathData = rE.aBoundaryPathData[j];
         if ( rPathData.bIsPolyLine )
         {
             for (const auto& a : rPathData.aP)
diff --git a/vcl/source/filter/idxf/dxfentrd.cxx 
b/vcl/source/filter/idxf/dxfentrd.cxx
index 2582b6a15b45..ba7cae6adb76 100644
--- a/vcl/source/filter/idxf/dxfentrd.cxx
+++ b/vcl/source/filter/idxf/dxfentrd.cxx
@@ -645,7 +645,7 @@ DXFHatchEntity::DXFHatchEntity() :
     nCurrentBoundaryPathIndex( -1 ),
     nFlags( 0 ),
     nAssociativityFlag( 0 ),
-    nBoundaryPathCount( 0 ),
+    nMaxBoundaryPathCount( 0 ),
     nHatchStyle( 0 ),
     nHatchPatternType( 0 ),
     fHatchPatternAngle( 0.0 ),
@@ -669,12 +669,12 @@ void DXFHatchEntity::EvaluateGroup( DXFGroupReader & rDGR 
)
         case 91 :
         {
             bIsInBoundaryPathContext = true;
-            nBoundaryPathCount = rDGR.GetI();
+            nMaxBoundaryPathCount = rDGR.GetI();
             // limit alloc to max reasonable size based on remaining data in 
stream
-            if (nBoundaryPathCount > 0 && 
o3tl::make_unsigned(nBoundaryPathCount) <= rDGR.remainingSize())
-                aBoundaryPathData.resize(nBoundaryPathCount);
+            if (nMaxBoundaryPathCount > 0 && 
o3tl::make_unsigned(nMaxBoundaryPathCount) > rDGR.remainingSize())
+                aBoundaryPathData.reserve(nMaxBoundaryPathCount);
             else
-                nBoundaryPathCount = 0;
+                nMaxBoundaryPathCount = 0;
         }
         break;
         case 75 :
@@ -699,9 +699,11 @@ void DXFHatchEntity::EvaluateGroup( DXFGroupReader & rDGR )
             bool bExecutingGroupCode = false;
             if ( bIsInBoundaryPathContext )
             {
-                if ( ( nCurrentBoundaryPathIndex >= 0 ) &&
-                    ( nCurrentBoundaryPathIndex < nBoundaryPathCount ) )
-                    bExecutingGroupCode = aBoundaryPathData[ 
nCurrentBoundaryPathIndex ].EvaluateGroup( rDGR );
+                if (nCurrentBoundaryPathIndex >= 0 && 
nCurrentBoundaryPathIndex < nMaxBoundaryPathCount)
+                {
+                    aBoundaryPathData.resize(nCurrentBoundaryPathIndex + 1);
+                    bExecutingGroupCode = 
aBoundaryPathData.back().EvaluateGroup(rDGR);
+                }
             }
             if ( !bExecutingGroupCode )
                 DXFBasicEntity::EvaluateGroup(rDGR);
diff --git a/vcl/source/filter/idxf/dxfentrd.hxx 
b/vcl/source/filter/idxf/dxfentrd.hxx
index 775d6a0844cb..85dbf7dd06b1 100644
--- a/vcl/source/filter/idxf/dxfentrd.hxx
+++ b/vcl/source/filter/idxf/dxfentrd.hxx
@@ -429,7 +429,7 @@ class DXFHatchEntity : public DXFBasicEntity
 
         sal_Int32   nFlags;                         // 70 (solid fill = 1, 
pattern fill = 0)
         sal_Int32   nAssociativityFlag;             // 71 (associative = 1, 
non-associative = 0)
-        sal_Int32   nBoundaryPathCount;             // 91
+        sal_Int32   nMaxBoundaryPathCount;          // 91
         sal_Int32   nHatchStyle;                    // 75 (odd parity = 0, 
outmost area = 1, entire area = 2 )
         sal_Int32   nHatchPatternType;              // 76 (user defined = 0, 
predefined = 1, custom = 2)
         double      fHatchPatternAngle;             // 52 (pattern fill only)

Reply via email to