pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Jackson (JIRA)" <j...@apache.org>
Subject [jira] Updated: (PDFBOX-856) NPE from PDPageLabels with a large number PDPageLabelRanges
Date Thu, 07 Oct 2010 15:15:31 GMT

     [ 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<PDNumberTreeNode> kids = node.getKids();
            for (PDNumberTreeNode kid : kids) {
                findLabels(kid);
            }
        }
        else if (node.getNumbers() != null) {
            @SuppressWarnings("unchecked")
            Map<Integer, COSDictionary> numbers = node.getNumbers();
            for (Entry<Integer, COSDictionary> 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<PDNumberTreeNode> kids = node.getKids();
            for (PDNumberTreeNode kid : kids) {
                findLabels(kid);
            }
        }
        else if (node.getNumbers() != null) {
            @SuppressWarnings("unchecked")
            Map<Integer, COSDictionary> numbers = node.getNumbers();
            for (Entry<Integer, COSDictionary> 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<PDNumberTreeNode> kids = node.getKids();
>             for (PDNumberTreeNode kid : kids) {
>                 findLabels(kid);
>             }
>         }
>         else if (node.getNumbers() != null) {
>             @SuppressWarnings("unchecked")
>             Map<Integer, COSDictionary> numbers = node.getNumbers();
>             for (Entry<Integer, COSDictionary> 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.


Mime
View raw message