]> source.dussan.org Git - poi.git/commitdiff
Hopefully fix bug #47271 - Avoid infinite loops on broken HWPF documents with a corru...
authorNick Burch <nick@apache.org>
Sun, 19 Sep 2010 10:16:06 +0000 (10:16 +0000)
committerNick Burch <nick@apache.org>
Sun, 19 Sep 2010 10:16:06 +0000 (10:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@998625 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java

index 5038f8314580a6ead7bd64572f2798c56d6f5837..9123d65c13b2d19d468cd42781c95b94bb885dff 100644 (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>
index 647746d82ee7bc8123dea5f0209b78b41f3e63ae..babad02b8d3aa8d4764e11ea83bc4d8bb3907e9a 100644 (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();