From bd7b37b8fcf193e2ce20a84ac68bdb22ed8a9ade Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 13 Jul 2015 08:33:50 +0100 Subject: emf: test for empty polygons Change-Id: I3c8896230e3d48a37f4b8d702b0f673e44f45ba4 (cherry picked from commit 7df4d8544c6b12e31bcb81d9389d03ae7c11bfea) Reviewed-on: https://gerrit.libreoffice.org/16974 Reviewed-by: David Tardon Tested-by: David Tardon --- .../graphicfilter/data/emf/fail/crash-2.emf | Bin 0 -> 3848 bytes vcl/source/filter/wmf/winmtf.cxx | 26 ++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 vcl/qa/cppunit/graphicfilter/data/emf/fail/crash-2.emf diff --git a/vcl/qa/cppunit/graphicfilter/data/emf/fail/crash-2.emf b/vcl/qa/cppunit/graphicfilter/data/emf/fail/crash-2.emf new file mode 100644 index 000000000000..6adabec8b31c Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/emf/fail/crash-2.emf differ diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx index e15f2e017e62..afa11a093a45 100644 --- a/vcl/source/filter/wmf/winmtf.cxx +++ b/vcl/source/filter/wmf/winmtf.cxx @@ -1283,18 +1283,22 @@ void WinMtfOutput::DrawPolyLine( Polygon& rPolygon, bool bTo, bool bRecordPath ) { UpdateClipRegion(); - ImplMap( rPolygon ); - if ( bTo ) - { - rPolygon[ 0 ] = maActPos; - maActPos = rPolygon[ rPolygon.GetSize() - 1 ]; - } - if ( bRecordPath ) - aPathObj.AddPolyLine( rPolygon ); - else + sal_uInt16 nPoints = rPolygon.GetSize(); + if (nPoints >= 1) { - UpdateLineStyle(); - mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) ); + ImplMap( rPolygon ); + if ( bTo ) + { + rPolygon[ 0 ] = maActPos; + maActPos = rPolygon[ rPolygon.GetSize() - 1 ]; + } + if ( bRecordPath ) + aPathObj.AddPolyLine( rPolygon ); + else + { + UpdateLineStyle(); + mpGDIMetaFile->AddAction( new MetaPolyLineAction( rPolygon, maLineStyle.aLineInfo ) ); + } } } -- cgit v1.2.3