This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git

commit d8b437b9c045094e4bb5bc3998b9e9dafcc296c1
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Apr 1 10:22:29 2024 -0400

    Avoid possible NullPointerException in
    
org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[])
---
 src/changes/changes.xml                                       |  1 +
 .../org/apache/bcel/classfile/ParameterAnnotationEntry.java   | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 5246fd3f..d8fc6196 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -69,6 +69,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.generic.ClassGen.ClassGen(JavaClass).</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.generic.FieldGenOrMethodGen.addAll(Attribute[]).</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid possible NullPointerException in 
org.apache.bcel.classfile.ParameterAnnotationEntry.createParameterAnnotationEntries(Attribute[]).</action>
       <!-- UPDATE -->
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.apache.commons:commons-parent from 66 to 67 
#283.</action>
       <action                  type="update" dev="ggregory" 
due-to="Dependabot">Bump org.jetbrains.kotlin:kotlin-stdlib from 1.9.22 to 
1.9.23 #284.</action>
diff --git 
a/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java 
b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
index f6aa2d27..70f6236e 100644
--- a/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
+++ b/src/main/java/org/apache/bcel/classfile/ParameterAnnotationEntry.java
@@ -32,10 +32,13 @@ public class ParameterAnnotationEntry implements Node {
 
     static final ParameterAnnotationEntry[] EMPTY_ARRAY = {};
 
-    public static ParameterAnnotationEntry[] 
createParameterAnnotationEntries(final Attribute[] attrs) {
+    public static ParameterAnnotationEntry[] 
createParameterAnnotationEntries(final Attribute[] attributes) {
+        if (attributes == null) {
+            return EMPTY_ARRAY;
+        }
         // Find attributes that contain parameter annotation data
-        final List<ParameterAnnotationEntry> accumulatedAnnotations = new 
ArrayList<>(attrs.length);
-        for (final Attribute attribute : attrs) {
+        final List<ParameterAnnotationEntry> accumulatedAnnotations = new 
ArrayList<>(attributes.length);
+        for (final Attribute attribute : attributes) {
             if (attribute instanceof ParameterAnnotations) {
                 final ParameterAnnotations runtimeAnnotations = 
(ParameterAnnotations) attribute;
                 final ParameterAnnotationEntry[] parameterAnnotationEntries = 
runtimeAnnotations.getParameterAnnotationEntries();
@@ -44,7 +47,7 @@ public class ParameterAnnotationEntry implements Node {
                 }
             }
         }
-        return 
accumulatedAnnotations.toArray(ParameterAnnotationEntry.EMPTY_ARRAY);
+        return accumulatedAnnotations.toArray(EMPTY_ARRAY);
     }
 
     private final AnnotationEntry[] annotationTable;

Reply via email to