From: Sergey Vladimirov Date: Sat, 9 Jul 2011 14:47:19 +0000 (+0000) Subject: add the same boundaries check to CHPX / PAPX / SEPX for Word95 as for Word97 X-Git-Tag: REL_3_8_BETA4~233 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=43d52c647f7f9fc7b1314977a90876b5030c9997;p=poi.git add the same boundaries check to CHPX / PAPX / SEPX for Word95 as for Word97 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1144681 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java index 089207dfb2..146fd3b3f7 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldCHPBinTable.java @@ -61,7 +61,9 @@ public final class OldCHPBinTable extends CHPBinTable for (int y = 0; y < fkpSize; y++) { - _textRuns.add(cfkp.getCHPX(y)); + CHPX chpx = cfkp.getCHPX(y); + if (chpx != null && tpt.isIndexInTable( chpx.getStartBytes(), chpx.getEndBytes() )) + _textRuns.add(chpx); } } Collections.sort( _textRuns, PropertyNode.StartComparator.instance ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java index b8b0fc3c23..9771e5efc9 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldPAPBinTable.java @@ -53,7 +53,8 @@ public final class OldPAPBinTable extends PAPBinTable for (int y = 0; y < fkpSize; y++) { PAPX papx = pfkp.getPAPX(y); - _paragraphs.add(papx); + if (papx != null && tpt.isIndexInTable( papx.getStartBytes(), papx.getEndBytes() )) + _paragraphs.add(papx); } } Collections.sort( _paragraphs, PropertyNode.StartComparator.instance ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java index db84825e08..2c212a6e33 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/OldSectionTable.java @@ -49,10 +49,11 @@ public final class OldSectionTable extends SectionTable int startAt = node.getStart(); int endAt = node.getEnd(); + SEPX sepx; // check for the optimization if (fileOffset == 0xffffffff) { - _sections.add(new SEPX(sed, startAt, endAt, charConv, new byte[0])); + sepx = new SEPX(sed, startAt, endAt, charConv, new byte[0]); } else { @@ -65,8 +66,11 @@ public final class OldSectionTable extends SectionTable byte[] buf = new byte[sepxSize+2]; fileOffset += LittleEndian.SHORT_SIZE; System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); - _sections.add(new SEPX(sed, startAt, endAt, charConv, buf)); + sepx = new SEPX(sed, startAt, endAt, charConv, buf); } + + if (tpt.isIndexInTable( sepx.getStartBytes(), sepx.getEndBytes() )) + _sections.add(sepx); } Collections.sort( _sections, PropertyNode.StartComparator.instance ); }