You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Kevin Jackson (JIRA)" <ji...@apache.org> on 2010/11/11 04:16:13 UTC

[jira] Created: (PDFBOX-891) Malformed document causes NPE in PDNameTreeNode.getValue

Malformed document causes NPE in PDNameTreeNode.getValue
--------------------------------------------------------

                 Key: PDFBOX-891
                 URL: https://issues.apache.org/jira/browse/PDFBOX-891
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.3.1
            Reporter: Kevin Jackson


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

Fix:

### 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 );
+                    }
                 }
             }
         }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


RE: [jira] Created: (PDFBOX-891) Malformed document causes NPE in PDNameTreeNode.getValue

Posted by Kevin Jackson <kj...@ebscohost.com>.
I agree that the document is not valid but a NPE is not the correct
result.
A log message would be fine but not required.

Kevin

-----Original Message-----
From: Adam@swmc.com [mailto:Adam@swmc.com] 
Sent: Thursday, November 11, 2010 12:29 PM
To: dev@pdfbox.apache.org
Cc: dev@pdfbox.apache.org
Subject: Re: [jira] Created: (PDFBOX-891) Malformed document causes NPE
in PDNameTreeNode.getValue

Isn't that a violation of the PDF spec?  If so, we should at least log a

message indicating that a problem was detected.

---- 
Thanks,
Adam





From:
"Kevin Jackson (JIRA)" <ji...@apache.org>
To:
dev@pdfbox.apache.org
Date:
11/10/2010 19:17
Subject:
[jira] Created: (PDFBOX-891) Malformed document causes NPE in 
PDNameTreeNode.getValue



Malformed document causes NPE in PDNameTreeNode.getValue
--------------------------------------------------------

                 Key: PDFBOX-891
                 URL: https://issues.apache.org/jira/browse/PDFBOX-891
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.3.1
            Reporter: Kevin Jackson


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

Fix:

### Eclipse Workspace Patch 1.0
#P pdfbox
Index: 
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.jav
a
===================================================================
--- 
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.jav
a  
 (revision 1026306)
+++ 
pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/PDNameTreeNode.jav
a  
 (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 );
+                    }
                 }
             }
         }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.






- FHA 203b; 203k; HECM; VA; USDA; Conventional 
- Warehouse Lines; FHA-Authorized Originators 
- Lending and Servicing in over 45 States 
www.swmc.com   -  www.simplehecmcalculator.com   
Visit  www.swmc.com/resources   for helpful links on Training, Webinars,
Lender Alerts and Submitting Conditions  

This email and any content within or attached hereto from Sun West
Mortgage Company, Inc. is confidential and/or legally privileged. The
information is intended only for the use of the individual or entity
named on this email. If you are not the intended recipient, you are
hereby notified that any disclosure, copying, distribution or taking any
action in reliance on the contents of this email information is strictly
prohibited, and that the documents should be returned to this office
immediately by email. Receipt by anyone other than the intended
recipient is not a waiver of any privilege. Please do not include your
social security number, account number, or any other personal or
financial information in the content of the email. Should you have any
questions, please call (800) 453 7884.  =

Re: [jira] Created: (PDFBOX-891) Malformed document causes NPE in PDNameTreeNode.getValue

Posted by Ad...@swmc.com.
Isn't that a violation of the PDF spec?  If so, we should at least log a 
message indicating that a problem was detected.

---- 
Thanks,
Adam





From:
"Kevin Jackson (JIRA)" <ji...@apache.org>
To:
dev@pdfbox.apache.org
Date:
11/10/2010 19:17
Subject:
[jira] Created: (PDFBOX-891) Malformed document causes NPE in 
PDNameTreeNode.getValue



Malformed document causes NPE in PDNameTreeNode.getValue
--------------------------------------------------------

                 Key: PDFBOX-891
                 URL: https://issues.apache.org/jira/browse/PDFBOX-891
             Project: PDFBox
          Issue Type: Bug
          Components: PDModel
    Affects Versions: 1.3.1
            Reporter: Kevin Jackson


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

Fix:

### 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 );
+                    }
                 }
             }
         }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.






- FHA 203b; 203k; HECM; VA; USDA; Conventional 
- Warehouse Lines; FHA-Authorized Originators 
- Lending and Servicing in over 45 States 
www.swmc.com   -  www.simplehecmcalculator.com   
Visit  www.swmc.com/resources   for helpful links on Training, Webinars, Lender Alerts and Submitting Conditions  

This email and any content within or attached hereto from Sun West Mortgage Company, Inc. is confidential and/or legally privileged. The information is intended only for the use of the individual or entity named on this email. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this email information is strictly prohibited, and that the documents should be returned to this office immediately by email. Receipt by anyone other than the intended recipient is not a waiver of any privilege. Please do not include your social security number, account number, or any other personal or financial information in the content of the email. Should you have any questions, please call (800) 453 7884.  

[jira] Commented: (PDFBOX-891) Malformed document causes NPE in PDNameTreeNode.getValue

Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PDFBOX-891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12931194#action_12931194 ] 

Adam Nichols commented on PDFBOX-891:
-------------------------------------

Kevin,
I should be able to get this committed either today or tomorrow.  BTW, do you have a sample PDF which you could upload?

> Malformed document causes NPE in PDNameTreeNode.getValue
> --------------------------------------------------------
>
>                 Key: PDFBOX-891
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-891
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.3.1
>            Reporter: Kevin Jackson
>
> If a NameTreeNode has neither a Names or Kids item, then getValue crashes with a Null Pointer Exception.
> Fix:
> ### 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 );
> +                    }
>                  }
>              }
>          }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PDFBOX-891) Malformed document causes NPE in PDNameTreeNode.getValue

Posted by "Adam Nichols (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PDFBOX-891?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adam Nichols resolved PDFBOX-891.
---------------------------------

    Resolution: Fixed
      Assignee: Adam Nichols

Patch has been committed in revision 1037069

> Malformed document causes NPE in PDNameTreeNode.getValue
> --------------------------------------------------------
>
>                 Key: PDFBOX-891
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-891
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 1.3.1
>            Reporter: Kevin Jackson
>            Assignee: Adam Nichols
>
> If a NameTreeNode has neither a Names or Kids item, then getValue crashes with a Null Pointer Exception.
> Fix:
> ### 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 );
> +                    }
>                  }
>              }
>          }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.