filter/source/graphicfilter/idxf/dxf2mtf.cxx | 13 ++++----- filter/source/graphicfilter/idxf/dxfentrd.cxx | 36 ++++++++++++++++++-------- filter/source/graphicfilter/idxf/dxfentrd.hxx | 11 +++++-- 3 files changed, 38 insertions(+), 22 deletions(-)
New commits: commit b1e1b0950ecc4bf7323bd494ef33de1ae31fedf0 Author: Caolán McNamara <caol...@redhat.com> Date: Sat Jan 13 21:22:08 2018 +0000 ofz#5276 oom Change-Id: I5eba89e0f242b316bd59779601dc1f12b8ce3b87 Reviewed-on: https://gerrit.libreoffice.org/47844 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx index 862ed03e3a20..9d034c579c9a 100644 --- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx +++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx @@ -531,13 +531,13 @@ void DXF2GDIMetaFile::DrawPolyLineEntity(const DXFPolyLineEntity & rE, const DXF void DXF2GDIMetaFile::DrawLWPolyLineEntity(const DXFLWPolyLineEntity & rE, const DXFTransform & rTransform ) { - sal_Int32 i, nPolySize = rE.nCount; - if ( nPolySize && rE.pP ) + sal_Int32 nPolySize = rE.aP.size(); + if (nPolySize) { tools::Polygon aPoly( static_cast<sal_uInt16>(nPolySize)); - for ( i = 0; i < nPolySize; i++ ) + for (sal_Int32 i = 0; i < nPolySize; ++i) { - rTransform.Transform( rE.pP[ static_cast<sal_uInt16>(i) ], aPoly[ static_cast<sal_uInt16>(i) ] ); + rTransform.Transform( rE.aP[ static_cast<sal_uInt16>(i) ], aPoly[ static_cast<sal_uInt16>(i) ] ); } if ( SetLineAttribute( rE ) ) { @@ -562,11 +562,10 @@ void DXF2GDIMetaFile::DrawHatchEntity(const DXFHatchEntity & rE, const DXFTransf const DXFBoundaryPathData& rPathData = rE.pBoundaryPathData[ j ]; if ( rPathData.bIsPolyLine ) { - sal_Int32 i; - for( i = 0; i < rPathData.nPointCount; i++ ) + for (const auto& a : rPathData.aP) { Point aPt; - rTransform.Transform( rPathData.pP[ i ], aPt ); + rTransform.Transform(a, aPt); aPtAry.push_back( aPt ); } } diff --git a/filter/source/graphicfilter/idxf/dxfentrd.cxx b/filter/source/graphicfilter/idxf/dxfentrd.cxx index 3c313a915be7..7a9074a0a770 100644 --- a/filter/source/graphicfilter/idxf/dxfentrd.cxx +++ b/filter/source/graphicfilter/idxf/dxfentrd.cxx @@ -423,7 +423,7 @@ void DXFLWPolyLineEntity::EvaluateGroup( DXFGroupReader & rDGR ) nCount = rDGR.GetI(); // limit alloc to max reasonable size based on remaining data in stream if (nCount > 0 && static_cast<sal_uInt32>(nCount) <= rDGR.remainingSize()) - pP.reset( new DXFVector[ nCount ] ); + aP.reserve(nCount); else nCount = 0; } @@ -434,14 +434,21 @@ void DXFLWPolyLineEntity::EvaluateGroup( DXFGroupReader & rDGR ) case 41: fEndWidth = rDGR.GetF(); break; case 10: { - if ( pP && ( nIndex < nCount ) ) - pP[ nIndex ].fx = rDGR.GetF(); + if (nIndex < nCount) + { + aP.resize(nIndex+1); + aP[nIndex].fx = rDGR.GetF(); + } } break; case 20: { - if ( pP && ( nIndex < nCount ) ) - pP[ nIndex++ ].fy = rDGR.GetF(); + if (nIndex < nCount) + { + aP.resize(nIndex+1); + aP[nIndex].fy = rDGR.GetF(); + ++nIndex; + } } break; default: DXFBasicEntity::EvaluateGroup(rDGR); @@ -548,10 +555,10 @@ bool DXFEdgeTypeSpline::EvaluateGroup( DXFGroupReader & rDGR ) } DXFBoundaryPathData::DXFBoundaryPathData() : + nPointCount( 0 ), nFlags( 0 ), nHasBulgeFlag( 0 ), nIsClosedFlag( 0 ), - nPointCount( 0 ), fBulge( 0.0 ), nSourceBoundaryObjects( 0 ), nEdgeCount( 0 ), @@ -583,7 +590,7 @@ bool DXFBoundaryPathData::EvaluateGroup( DXFGroupReader & rDGR ) nPointCount = rDGR.GetI(); // limit alloc to max reasonable size based on remaining data in stream if (nPointCount > 0 && static_cast<sal_uInt32>(nPointCount) <= rDGR.remainingSize()) - pP.reset( new DXFVector[ nPointCount ] ); + aP.reserve(nPointCount); else nPointCount = 0; } @@ -594,14 +601,21 @@ bool DXFBoundaryPathData::EvaluateGroup( DXFGroupReader & rDGR ) case 42 : fBulge = rDGR.GetF(); break; case 10: { - if ( pP && ( nPointIndex < nPointCount ) ) - pP[ nPointIndex ].fx = rDGR.GetF(); + if (nPointIndex < nPointCount) + { + aP.resize(nPointIndex+1); + aP[nPointIndex].fx = rDGR.GetF(); + } } break; case 20: { - if ( pP && ( nPointIndex < nPointCount ) ) - pP[ nPointIndex++ ].fy = rDGR.GetF(); + if (nPointIndex < nPointCount) + { + aP.resize(nPointIndex+1); + aP[nPointIndex].fy = rDGR.GetF(); + ++nPointIndex; + } } break; diff --git a/filter/source/graphicfilter/idxf/dxfentrd.hxx b/filter/source/graphicfilter/idxf/dxfentrd.hxx index 405ae13e7970..39d9b12fbff6 100644 --- a/filter/source/graphicfilter/idxf/dxfentrd.hxx +++ b/filter/source/graphicfilter/idxf/dxfentrd.hxx @@ -25,6 +25,7 @@ #include <deque> #include <memory> +#include <vector> enum DXFEntityType { DXF_LINE, @@ -323,16 +324,16 @@ protected: class DXFLWPolyLineEntity : public DXFBasicEntity { sal_Int32 nIndex; + sal_Int32 nCount; // 90 public: - sal_Int32 nCount; // 90 sal_Int32 nFlags; // 70 1 = closed, 128 = plinegen double fConstantWidth; // 43 (optional - default: 0, not used if fStartWidth and/or fEndWidth is used) double fStartWidth; // 40 double fEndWidth; // 41 - std::unique_ptr<DXFVector[]> pP; + std::vector<DXFVector> aP; DXFLWPolyLineEntity(); @@ -400,10 +401,12 @@ struct DXFEdgeTypeSpline : public DXFEdgeType struct DXFBoundaryPathData { +private: + sal_Int32 nPointCount; // 93 +public: sal_Int32 nFlags; // 92 sal_Int32 nHasBulgeFlag; // 72 sal_Int32 nIsClosedFlag; // 73 - sal_Int32 nPointCount; // 93 double fBulge; // 42 sal_Int32 nSourceBoundaryObjects; // 97 sal_Int32 nEdgeCount; // 93 @@ -411,7 +414,7 @@ struct DXFBoundaryPathData bool bIsPolyLine; sal_Int32 nPointIndex; - std::unique_ptr<DXFVector[]> pP; + std::vector<DXFVector> aP; std::deque<std::unique_ptr<DXFEdgeType>> aEdges; DXFBoundaryPathData(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits