From b4d748f24212bac2e6b57c79b195579a645b8527 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Mon, 31 Jan 2011 09:55:10 +0000 Subject: [PATCH] hwpf: ignore invalid style reference git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1065538 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hwpf/model/StyleSheet.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 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 c3e66f6e78..2d10335c9f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java @@ -321,11 +321,22 @@ public final class StyleSheet implements HDFType { public ParagraphProperties getParagraphStyle(int x) { - if (x == NIL_STYLE) - { + if (x == NIL_STYLE) { + return NIL_PAP; + } + + if (x >= _styleDescriptions.length) { + return NIL_PAP; + } + + if (_styleDescriptions[x]==null) { + return NIL_PAP; + } + + if (_styleDescriptions[x].getPAP()==null) { return NIL_PAP; } - return (_styleDescriptions[x] != null ? _styleDescriptions[x].getPAP() : null); - } + return _styleDescriptions[x].getPAP(); + } } -- 2.39.5