]> source.dussan.org Git - poi.git/commitdiff
Prevent infinite recursion (leading to stack overflow) on broken documents where...
authorNick Burch <nick@apache.org>
Mon, 3 Apr 2006 16:46:01 +0000 (16:46 +0000)
committerNick Burch <nick@apache.org>
Mon, 3 Apr 2006 16:46:01 +0000 (16:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@391084 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java

index 36b488341f8e01c4edbd22b23beb1cf04b049d9d..b1dd70e8b5d40a3921cdd6a51a352562fbd96fea 100644 (file)
@@ -230,10 +230,16 @@ public class StyleSheet implements HDFType
           {
 
               parentPAP = _styleDescriptions[baseIndex].getPAP();
-              if(parentPAP == null)
+              if(parentPAP == null) 
               {
-                  createPap(baseIndex);
-                  parentPAP = _styleDescriptions[baseIndex].getPAP();
+                 if(baseIndex == istd) {
+                         // Oh dear, style claims that it is its own parent
+                         throw new IllegalStateException("Pap style " + istd + " claimed to have itself as its parent, which isn't allowed");
+                 } else {
+                         // Create the parent style
+                      createPap(baseIndex);
+                      parentPAP = _styleDescriptions[baseIndex].getPAP();
+                 }
               }
 
           }