Return-Path: Delivered-To: apmail-pdfbox-dev-archive@www.apache.org Received: (qmail 43176 invoked from network); 7 Oct 2010 15:15:53 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Oct 2010 15:15:53 -0000 Received: (qmail 71043 invoked by uid 500); 7 Oct 2010 15:15:53 -0000 Delivered-To: apmail-pdfbox-dev-archive@pdfbox.apache.org Received: (qmail 71007 invoked by uid 500); 7 Oct 2010 15:15:53 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 70993 invoked by uid 99); 7 Oct 2010 15:15:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 15:15:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 15:15:52 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o97FFVqv000716 for ; Thu, 7 Oct 2010 15:15:32 GMT Message-ID: <23982524.26281286464531741.JavaMail.jira@thor> Date: Thu, 7 Oct 2010 11:15:31 -0400 (EDT) From: "Kevin Jackson (JIRA)" To: dev@pdfbox.apache.org Subject: [jira] Updated: (PDFBOX-856) NPE from PDPageLabels with a large number PDPageLabelRanges In-Reply-To: <23373186.26261286464413260.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-856?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kevin Jackson updated PDFBOX-856: --------------------------------- Description: Section 3.8.6 states that number trees have either "Nums" or "Kids" entries. The current PDPageLabels does not handle Kids and fails with a NPE. Fix: public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException { this(document); if (dict == null) { return; } PDNumberTreeNode root = new PDNumberTreeNode(dict, COSDictionary.class); findLabels(root); } private void findLabels(PDNumberTreeNode node) throws IOException { if (node.getKids() != null) { @SuppressWarnings("unchecked") List kids = node.getKids(); for (PDNumberTreeNode kid : kids) { findLabels(kid); } } else if (node.getNumbers() != null) { @SuppressWarnings("unchecked") Map numbers = node.getNumbers(); for (Entry i : numbers.entrySet()) { labels.put(i.getKey(), new PDPageLabelRange(i.getValue())); } } } was: Section 3.8.6 states that number trees either "Nums" or "Kids" entries. The current PDPageLabels does not handle Kids and fails with a NPE. Fix: public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException { this(document); if (dict == null) { return; } PDNumberTreeNode root = new PDNumberTreeNode(dict, COSDictionary.class); findLabels(root); } private void findLabels(PDNumberTreeNode node) throws IOException { if (node.getKids() != null) { @SuppressWarnings("unchecked") List kids = node.getKids(); for (PDNumberTreeNode kid : kids) { findLabels(kid); } } else if (node.getNumbers() != null) { @SuppressWarnings("unchecked") Map numbers = node.getNumbers(); for (Entry i : numbers.entrySet()) { labels.put(i.getKey(), new PDPageLabelRange(i.getValue())); } } } > NPE from PDPageLabels with a large number PDPageLabelRanges > ----------------------------------------------------------- > > Key: PDFBOX-856 > URL: https://issues.apache.org/jira/browse/PDFBOX-856 > Project: PDFBox > Issue Type: Bug > Components: PDModel > Affects Versions: 1.2.1 > Reporter: Kevin Jackson > > Section 3.8.6 states that number trees have either "Nums" or "Kids" entries. The current PDPageLabels does not handle Kids and fails with a NPE. > Fix: > public PDPageLabels(PDDocument document, COSDictionary dict) throws IOException > { > this(document); > if (dict == null) > { > return; > } > PDNumberTreeNode root = new PDNumberTreeNode(dict, COSDictionary.class); > findLabels(root); > } > private void findLabels(PDNumberTreeNode node) throws IOException { > if (node.getKids() != null) { > @SuppressWarnings("unchecked") > List kids = node.getKids(); > for (PDNumberTreeNode kid : kids) { > findLabels(kid); > } > } > else if (node.getNumbers() != null) { > @SuppressWarnings("unchecked") > Map numbers = node.getNumbers(); > for (Entry i : numbers.entrySet()) > { > labels.put(i.getKey(), new PDPageLabelRange(i.getValue())); > } > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.