From 16834ecb23ad0feef13cf80b8af9c9b366a8ed64 Mon Sep 17 00:00:00 2001 From: Maxim Date: Thu, 9 Nov 2023 17:45:01 +0300 Subject: [PATCH] Fix NullPointerException in getParentLang in PBoxPDStructElem --- .../org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java index f22921e4..bd8495ab 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDStructElem.java @@ -168,15 +168,18 @@ public String getstandardType() { @Override public String getparentLang() { - COSString baseLang = null; - Set keys = new HashSet<>(); - COSObjectKey key; COSDictionary parentDict = (COSDictionary)((COSDictionary) this.simplePDObject).getDictionaryObject(COSName.P); + if (parentDict == null) { + return null; + } PDStructureNode structureParent = PDStructureNode.create(parentDict); PDStructureElement parent = null; if (structureParent instanceof PDStructureElement) { parent = (PDStructureElement) structureParent; } + COSString baseLang = null; + Set keys = new HashSet<>(); + COSObjectKey key; while (baseLang == null && parent != null) { key = parent.getCOSObject().getKey(); if (keys.contains(key)){