Hopefully fix bug #47271 - Avoid infinite loops on broken HWPF documents with a corrupt CHP style with a parent of itself

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@998625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2010-09-19 10:16:06 +00:00
parent 8043f38bd7
commit 1e2b747f8f
2 changed files with 11 additions and 0 deletions

View File

@ -34,6 +34,7 @@
<changes>
<release version="3.7-beta3" date="2010-??-??">
<action dev="poi-developers" type="fix">47271 - Avoid infinite loops on broken HWPF documents with a corrupt CHP style with a parent of itself</action>
<action dev="poi-developers" type="fix">49936 - Handle HWPF documents with problematic HeaderStories better</action>
<action dev="poi-developers" type="fix">49933 - Support sections in Word 6 and Word 95 files (HWPFOldDocument)</action>
<action dev="poi-developers" type="fix">49941 - Correctly handle space preservation of XSSFRichTextRuns when applying fonts to parts of the string</action>

View File

@ -258,6 +258,16 @@ public final class StyleSheet implements HDFType {
CharacterProperties chp = sd.getCHP();
byte[] chpx = sd.getCHPX();
int baseIndex = sd.getBaseStyle();
if(baseIndex == istd) {
// Oh dear, this isn't allowed...
// The word file seems to be corrupted
// Switch to using the nil style so that
// there's a chance we can read it
baseIndex = NIL_STYLE;
}
// Build and decompress the Chp if required
if(chp == null && chpx != null)
{
CharacterProperties parentCHP = new CharacterProperties();