From e5813e6cf8a197ae6c560c98fafb3e5aa36b0fdb Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 3 Apr 2006 16:46:01 +0000 Subject: [PATCH] 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 --- .../src/org/apache/poi/hwpf/model/StyleSheet.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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(); + } } } -- 2.39.5