commons-bcel icon indicating copy to clipboard operation
commons-bcel copied to clipboard

Add null guard for InstructionFactor.createInvoke

Open pingpingy1 opened this issue 1 year ago • 0 comments

In the current implementation of the createInvoke method, an NPE is thrown if the argTypes array is null. This commit adds a null guard that skips the for loop if this is the case.

Example:

public static void main(String args[]) {
  InstructionFactory factory= new InstructionFactory(new ClassGen(Repository.lookupClass(Object.class)));
  factory.createInvoke("", "", Type.VOID, null, Const.INVOKESPECIAL, false);
}
Exception in thread "main" java.lang.NullPointerException
        at org.apache.bcel.generic.InstructionFactory.createInvoke(InstructionFactory.java:643)
        at Test.main(Test.java:11)

pingpingy1 avatar Mar 19 '24 08:03 pingpingy1