Avoid a rare ArrayIndexOutOfBoundsException on some word table stuff (patch from bug #44078)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@604878 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fc52062484
commit
f08243b10f
@ -148,7 +148,9 @@ public class TableSprmUncompressor
|
||||
|
||||
for (int x = 0; x < itcMac; x++)
|
||||
{
|
||||
if(hasTCs) rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl,
|
||||
// Sometimes, the grpprl does not contain data at every offset. I have no idea why this happens.
|
||||
if(hasTCs && offset + (1 + ( (itcMac + 1) * 2) + (x * 20)) < grpprl.length)
|
||||
rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl,
|
||||
offset + (1 + ( (itcMac + 1) * 2) + (x * 20)));
|
||||
else
|
||||
rgtc[x] = new TableCellDescriptor();
|
||||
|
BIN
src/scratchpad/testcases/org/apache/poi/hwpf/data/AIOOB-Tap.doc
Normal file
BIN
src/scratchpad/testcases/org/apache/poi/hwpf/data/AIOOB-Tap.doc
Normal file
Binary file not shown.
@ -53,7 +53,24 @@ public class TestProblems extends TestCase {
|
||||
Section s = r.getSection(x);
|
||||
for (int y = 0; y < s.numParagraphs(); y++) {
|
||||
Paragraph paragraph = s.getParagraph(y);
|
||||
System.out.println(paragraph.getCharacterRun(0).text());
|
||||
//System.out.println(paragraph.getCharacterRun(0).text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* AIOOB for TableSprmUncompressor.unCompressTAPOperation
|
||||
*/
|
||||
public void testSprmAIOOB() throws Exception {
|
||||
HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/AIOOB-Tap.doc"));
|
||||
|
||||
Range r = doc.getRange();
|
||||
StyleSheet styleSheet = doc.getStyleSheet();
|
||||
for (int x = 0; x < r.numSections(); x++) {
|
||||
Section s = r.getSection(x);
|
||||
for (int y = 0; y < s.numParagraphs(); y++) {
|
||||
Paragraph paragraph = s.getParagraph(y);
|
||||
//System.out.println(paragraph.getCharacterRun(0).text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user