Author: tilman
Date: Thu Apr 10 14:12:59 2025
New Revision: 1924995

URL: http://svn.apache.org/viewvc?rev=1924995&view=rev
Log:
PDFBOX-5984: avoid NPE

Modified:
    
pdfbox/branches/1.8/jempbox/src/main/java/org/apache/jempbox/impl/XMLUtil.java

Modified: 
pdfbox/branches/1.8/jempbox/src/main/java/org/apache/jempbox/impl/XMLUtil.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/1.8/jempbox/src/main/java/org/apache/jempbox/impl/XMLUtil.java?rev=1924995&r1=1924994&r2=1924995&view=diff
==============================================================================
--- 
pdfbox/branches/1.8/jempbox/src/main/java/org/apache/jempbox/impl/XMLUtil.java 
(original)
+++ 
pdfbox/branches/1.8/jempbox/src/main/java/org/apache/jempbox/impl/XMLUtil.java 
Thu Apr 10 14:12:59 2025
@@ -160,15 +160,20 @@ public class XMLUtil
      * @param parent The parent element that holds the values.
      * @param nodeName The name of the node that holds the integer value.
      * 
-     * @return The integer value of the node.
+     * @return The integer value of the node or null.
      */
     public static Integer getIntValue( Element parent, String nodeName )
     {
-        String intVal = XMLUtil.getStringValue( XMLUtil.getElement( parent, 
nodeName ) );
+        Element element = XMLUtil.getElement( parent, nodeName );
+        if (element == null)
+        {
+            return null;
+        }
+        String intVal = XMLUtil.getStringValue( element );
         Integer retval = null;
         if( intVal != null )
         {
-            retval = new Integer( intVal );
+            retval = Integer.valueOf(intVal);
         }
         return retval;
     }
@@ -211,11 +216,16 @@ public class XMLUtil
      * @param parent The parent element that holds the values.
      * @param nodeName The name of the node that holds the value.
      * 
-     * @return The value of the sub node.
+     * @return The value of the sub node or null.
      */
     public static String getStringValue( Element parent, String nodeName )
     {
-        return XMLUtil.getStringValue( XMLUtil.getElement( parent, nodeName ) 
);
+        Element element = XMLUtil.getElement(parent, nodeName);
+        if (element == null)
+        {
+            return null;
+        }
+        return XMLUtil.getStringValue(element);
     }
     
     /**


Reply via email to