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
This commit is contained in:
Sergey Vladimirov 2011-07-09 14:47:19 +00:00
parent 1272107604
commit 530a209d01
3 changed files with 11 additions and 4 deletions

View File

@ -61,7 +61,9 @@ public final class OldCHPBinTable extends CHPBinTable
for (int y = 0; y < fkpSize; y++) 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 ); Collections.sort( _textRuns, PropertyNode.StartComparator.instance );

View File

@ -53,6 +53,7 @@ public final class OldPAPBinTable extends PAPBinTable
for (int y = 0; y < fkpSize; y++) for (int y = 0; y < fkpSize; y++)
{ {
PAPX papx = pfkp.getPAPX(y); PAPX papx = pfkp.getPAPX(y);
if (papx != null && tpt.isIndexInTable( papx.getStartBytes(), papx.getEndBytes() ))
_paragraphs.add(papx); _paragraphs.add(papx);
} }
} }

View File

@ -49,10 +49,11 @@ public final class OldSectionTable extends SectionTable
int startAt = node.getStart(); int startAt = node.getStart();
int endAt = node.getEnd(); int endAt = node.getEnd();
SEPX sepx;
// check for the optimization // check for the optimization
if (fileOffset == 0xffffffff) 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 else
{ {
@ -65,8 +66,11 @@ public final class OldSectionTable extends SectionTable
byte[] buf = new byte[sepxSize+2]; byte[] buf = new byte[sepxSize+2];
fileOffset += LittleEndian.SHORT_SIZE; fileOffset += LittleEndian.SHORT_SIZE;
System.arraycopy(documentStream, fileOffset, buf, 0, buf.length); 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 ); Collections.sort( _sections, PropertyNode.StartComparator.instance );
} }