From: Maxim Valyanskiy Date: Mon, 31 Jan 2011 09:55:10 +0000 (+0000) Subject: hwpf: ignore invalid style reference X-Git-Tag: REL_3_8_BETA1~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b4d748f24212bac2e6b57c79b195579a645b8527;p=poi.git hwpf: ignore invalid style reference git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1065538 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 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(); + } }