]> source.dussan.org Git - poi.git/commitdiff
hwpf: ignore invalid style reference
authorMaxim Valyanskiy <maxcom@apache.org>
Mon, 31 Jan 2011 09:55:10 +0000 (09:55 +0000)
committerMaxim Valyanskiy <maxcom@apache.org>
Mon, 31 Jan 2011 09:55:10 +0000 (09:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1065538 13f79535-47bb-0310-9956-ffa450edef68

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

index c3e66f6e780c36a6429ee4b067f9fbd3b40f4a4b..2d10335c9fb6f21878a6eb9af6b40dfc760b4ec6 100644 (file)
@@ -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();
+  }
 }