From 2125c37d31050241f9f0dd3dcea111cd1bf7f134 Mon Sep 17 00:00:00 2001 From: Andreas Beeker Date: Wed, 6 Jan 2021 23:14:45 +0000 Subject: [PATCH] #65063 - WMF parsing failed on closed empty polygon git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885215 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hwmf/record/HwmfDraw.java | 10 +++++----- .../org/apache/poi/hwmf/TestHwmfParsing.java | 15 +++++++++++---- test-data/slideshow/empty-polygon-close.wmf | Bin 0 -> 20644 bytes 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 test-data/slideshow/empty-polygon-close.wmf diff --git a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java index 12eb580f93..1c99601642 100644 --- a/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java +++ b/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java @@ -143,10 +143,10 @@ public final class HwmfDraw { @Override public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { //A 16-bit signed integer that defines the number of points in the array. - int numberofPoints = leis.readShort(); + int numberOfPoints = leis.readShort(); - poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, numberofPoints); - for (int i=0; i 0 && addClose()) { // polygons are closed / polylines not poly.closePath(); } - return LittleEndianConsts.SHORT_SIZE+numberofPoints*LittleEndianConsts.INT_SIZE; + return LittleEndianConsts.SHORT_SIZE+numberOfPoints*LittleEndianConsts.INT_SIZE; } @Override diff --git a/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java b/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java index ebb829a9b3..d1440c0c32 100644 --- a/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java +++ b/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java @@ -39,6 +39,8 @@ import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.RecordFormatException; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; public class TestHwmfParsing { @@ -48,12 +50,17 @@ public class TestHwmfParsing { // for manual mass parsing and rendering tests of .wmfs use HemfPictureTest.paint() ! // ****************************************************************************** - @Test - public void parse() throws IOException { - try (InputStream fis = samples.openResourceAsStream("santa.wmf")) { + @ParameterizedTest + @CsvSource({ + "santa.wmf, 581", + /* Bug 65063 */ + "empty-polygon-close.wmf, 272" + }) + public void parse(String file, int recordCnt) throws IOException { + try (InputStream fis = samples.openResourceAsStream(file)) { HwmfPicture wmf = new HwmfPicture(fis); List records = wmf.getRecords(); - assertEquals(581, records.size()); + assertEquals(recordCnt, records.size()); } } diff --git a/test-data/slideshow/empty-polygon-close.wmf b/test-data/slideshow/empty-polygon-close.wmf new file mode 100644 index 0000000000000000000000000000000000000000..44aa7cfe23d0244d690c837ececc7a7ab10e7342 GIT binary patch literal 20644 zcmY-137pl{mEiGz6(*fUqcLU`H{9YHTmVrBI}}Ahu|o-B)R<@#HC60X6^mj5?krXn zTP?^Ui)_kb6`(?qOixGc0VFDrba$qc={Czu`qMq>$$T>3b06V-21=( z|Nq|m?yHxRKRdcIOaHsN)336Uq}7it%08QAorZif%ZjtHox=Dje7-oZom>2??CMTo zJE!Qpv)-GFzIIkCE-E^!eYQ}esQ52``AZh5F3tYNzklWliww9)h0l=xS^TLi>c;zJ3WXNhZCQamSnrg&lYT=A0Zh2o{z(&C0}MR8NsP`pv>Hg$HZzb|{OxGj65 z_^s?f@!_n!xIKHf_^5V&lKqnWAIkre{ZIT^r#AiFr|-L6!?x_poi=7)@6?oa?$nT7 z)@f;WMW-d%m7NwE(>bWb!^-!uSMZM(S1NvhdcD=}F3&CU-6-$1@?WK$E3|j1b}!NX zCHirR{#>eGSLokW`gyJX-l*TV=zn+D(cAS5a9yRYZ?x;IaJ~1r?uQZgv@$zhbU6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