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 0aebd69e9fa517a044c491d23fcf2bc22bbe5d09
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Apr 1 11:28:46 2024 -0400

    Avoid NullPointerException calling
    org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null
---
 src/changes/changes.xml                              | 1 +
 src/main/java/org/apache/bcel/generic/MethodGen.java | 8 +++-----
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4d0d81a0..7004873e 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -92,6 +92,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException calling 
org.apache.bcel.generic.InstructionList.redirectLocalVariables(LocalVariableGen[],
 InstructionHandle, InstructionHandle) with null.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException calling 
org.apache.bcel.generic.InstructionList.redirectExceptionHandlers(CodeExceptionGen[],
 InstructionHandle, InstructionHandle) with null.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException calling 
org.apache.bcel.generic.InstructionList.findHandle(InstructionHandle[], int[], 
int, int) with null.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Avoid NullPointerException calling 
org.apache.bcel.generic.MethodGen.setArgumentTypes(Type[]) with null.</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/generic/MethodGen.java 
b/src/main/java/org/apache/bcel/generic/MethodGen.java
index 1cccda44..37e21679 100644
--- a/src/main/java/org/apache/bcel/generic/MethodGen.java
+++ b/src/main/java/org/apache/bcel/generic/MethodGen.java
@@ -1042,7 +1042,7 @@ public class MethodGen extends FieldGenOrMethodGen {
     }
 
     public void setArgumentTypes(final Type[] argTypes) {
-        this.argTypes = argTypes;
+        this.argTypes = argTypes != null ? argTypes : Type.NO_ARGS;
     }
 
     public void setClassName(final String className) { // TODO could be 
package-protected?
@@ -1059,10 +1059,8 @@ public class MethodGen extends FieldGenOrMethodGen {
     public void setMaxLocals() { // TODO could be package-protected? (some 
tests would need repackaging)
         if (il != null) {
             int max = isStatic() ? 0 : 1;
-            if (argTypes != null) {
-                for (final Type argType : argTypes) {
-                    max += argType.getSize();
-                }
+            for (final Type argType : argTypes) {
+                max += argType.getSize();
             }
             for (InstructionHandle ih = il.getStart(); ih != null; ih = 
ih.getNext()) {
                 final Instruction ins = ih.getInstruction();

Reply via email to