From: Nick Burch Date: Mon, 3 Apr 2006 16:46:01 +0000 (+0000) Subject: Prevent infinite recursion (leading to stack overflow) on broken documents where... X-Git-Tag: REL_3_0_ALPHA3~137 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e5813e6cf8a197ae6c560c98fafb3e5aa36b0fdb;p=poi.git Prevent infinite recursion (leading to stack overflow) on broken documents where a PAP claims to be its own parent git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@391084 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java b/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java index 36b488341f..b1dd70e8b5 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java @@ -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(); + } } }