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 70d765683d
commit 43d52c647f
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++)
{
_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 );

View File

@ -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 );

View File

@ -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 );
}