Program: 40409
Project: 40409
Buggy source:
/** 
 * Add a New statement of the given type
 * @return instruction added, or null
 * @throws IllegalArgumentException if T is null
 */
private SSANewInstruction addAllocation(TypeReference T,boolean invokeCtor){
  if (T == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int instance=nextLocal++;
  SSANewInstruction result=null;
  if (T.isReferenceType()) {
    NewSiteReference ref=NewSiteReference.make(statements.size(),T);
    if (T.isArrayType()) {
      int[] sizes=new int[T.getDimensionality()];
      Arrays.fill(sizes,getValueNumberForIntConstant(1));
      result=new SSANewInstruction(instance,ref,sizes);
    }
 else {
      result=new SSANewInstruction(instance,ref);
    }
    statements.add(result);
    IClass klass=cha.lookupClass(T);
    if (klass == null) {
      Warnings.add(AllocationFailure.create(T));
      return null;
    }
    if (klass.isArrayClass()) {
      int arrayRef=result.getDef();
      TypeReference e=klass.getReference().getArrayElementType();
      while (e != null && !e.isPrimitiveType()) {
        NewSiteReference n=NewSiteReference.make(statements.size(),e);
        int alloc=nextLocal++;
        SSANewInstruction ni=null;
        if (e.isArrayType()) {
          int[] sizes=new int[T.getDimensionality()];
          Arrays.fill(sizes,getValueNumberForIntConstant(1));
          ni=new SSANewInstruction(alloc,n,sizes);
        }
 else {
          ni=new SSANewInstruction(alloc,n);
        }
        statements.add(ni);
        SSAArrayStoreInstruction store=new SSAArrayStoreInstruction(arrayRef,0,alloc,e);
        statements.add(store);
        e=e.isArrayType() ? e.getArrayElementType() : null;
        arrayRef=alloc;
      }
    }
    if (invokeCtor) {
      IMethod ctor=cha.resolveMethod(klass,MethodReference.initSelector);
      if (ctor != null) {
        addInvocation(new int[]{instance},CallSiteReference.make(statements.size(),ctor.getReference(),IInvokeInstruction.Dispatch.SPECIAL));
      }
    }
  }
  cache.invalidate(this,Everywhere.EVERYWHERE);
  return result;
}

Fixed version (ground truth):
/** 
 * Add a New statement of the given type
 * @return instruction added, or null
 * @throws IllegalArgumentException if T is null
 */
private SSANewInstruction addAllocation(TypeReference T,boolean invokeCtor){
  if (T == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  int instance=nextLocal++;
  SSANewInstruction result=null;
  if (T.isReferenceType()) {
    NewSiteReference ref=NewSiteReference.make(statements.size(),T);
    if (T.isArrayType()) {
      int[] sizes=new int[T.getDimensionality()];
      Arrays.fill(sizes,getValueNumberForIntConstant(1));
      result=new SSANewInstruction(instance,ref,sizes);
    }
 else {
      result=new SSANewInstruction(instance,ref);
    }
    statements.add(result);
    IClass klass=cha.lookupClass(T);
    if (klass == null) {
      Warnings.add(AllocationFailure.create(T));
      return null;
    }
    if (klass.isArrayClass()) {
      int arrayRef=result.getDef();
      TypeReference e=klass.getReference().getArrayElementType();
      while (e != null && !e.isPrimitiveType()) {
        NewSiteReference n=NewSiteReference.make(statements.size(),e);
        int alloc=nextLocal++;
        SSANewInstruction ni=null;
        if (e.isArrayType()) {
          int[] sizes=new int[T.getDimensionality()];
          Arrays.fill(sizes,getValueNumberForIntConstant(1));
          ni=new SSANewInstruction(alloc,n,sizes);
        }
 else {
          ni=new SSANewInstruction(alloc,n);
        }
        statements.add(ni);
        SSAArrayStoreInstruction store=new SSAArrayStoreInstruction(arrayRef,getValueNumberForIntConstant(0),alloc,e);
        statements.add(store);
        e=e.isArrayType() ? e.getArrayElementType() : null;
        arrayRef=alloc;
      }
    }
    if (invokeCtor) {
      IMethod ctor=cha.resolveMethod(klass,MethodReference.initSelector);
      if (ctor != null) {
        addInvocation(new int[]{instance},CallSiteReference.make(statements.size(),ctor.getReference(),IInvokeInstruction.Dispatch.SPECIAL));
      }
    }
  }
  cache.invalidate(this,Everywhere.EVERYWHERE);
  return result;
}