Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-891

Malformed document causes NPE in PDNameTreeNode.getValue

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.3.1
    • 1.4.0
    • PDModel
    • None

    Description

      If a NameTreeNode has neither a Names or Kids item, then getValue crashes with a Null Pointer Exception.

      Fix:

          1. Eclipse Workspace Patch 1.0
            #P pdfbox
            Index: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java
            ===================================================================
          • pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java (revision 1026306)
            +++ pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.java (working copy)
            @@ -147,13 +147,15 @@
            else
            {
            List kids = getKids();
      • for( int i=0; i<kids.size() && retval == null; i++ )
      • {
      • PDNameTreeNode childNode = (PDNameTreeNode)kids.get( i );
      • if( childNode.getLowerLimit().compareTo( name ) <= 0 &&
      • childNode.getUpperLimit().compareTo( name ) >= 0 )
        + if (kids != null) {
        + for( int i=0; i<kids.size() && retval == null; i++ )
        {
      • retval = childNode.getValue( name );
        + PDNameTreeNode childNode = (PDNameTreeNode)kids.get( i );
        + if( childNode.getLowerLimit().compareTo( name ) <= 0 &&
        + childNode.getUpperLimit().compareTo( name ) >= 0 )
        + { + retval = childNode.getValue( name ); + }

        }
        }
        }

      Attachments

        Activity

          People

            adamnichols Adam Nichols
            kevinjackson Kevin Jackson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: