mirror of https://github.com/apache/poi.git
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
a1f9da0930
commit
e5f8b9951c
|
@ -148,8 +148,10 @@ public class TableSprmUncompressor
|
||||||
|
|
||||||
for (int x = 0; x < itcMac; x++)
|
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.
|
||||||
offset + (1 + ( (itcMac + 1) * 2) + (x * 20)));
|
if(hasTCs && offset + (1 + ( (itcMac + 1) * 2) + (x * 20)) < grpprl.length)
|
||||||
|
rgtc[x] = TableCellDescriptor.convertBytesToTC(grpprl,
|
||||||
|
offset + (1 + ( (itcMac + 1) * 2) + (x * 20)));
|
||||||
else
|
else
|
||||||
rgtc[x] = new TableCellDescriptor();
|
rgtc[x] = new TableCellDescriptor();
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -53,8 +53,25 @@ public class TestProblems extends TestCase {
|
||||||
Section s = r.getSection(x);
|
Section s = r.getSection(x);
|
||||||
for (int y = 0; y < s.numParagraphs(); y++) {
|
for (int y = 0; y < s.numParagraphs(); y++) {
|
||||||
Paragraph paragraph = s.getParagraph(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