Program: 61510
Project: 61510
Buggy source:
public AVM2Code(ABCInputStream ais,MethodBody body) throws IOException {
  Map<Long,AVM2Instruction> codeMap=new HashMap<>();
  DumpInfo diParent=ais.dumpInfo;
  List<Long> addresses=new ArrayList<>();
  List<Long> unAdresses=new ArrayList<>();
  List<Long> switchAddresses=new ArrayList<>();
  int availableBytes=ais.available();
  for (int i=0; i < availableBytes; i++) {
    codeMap.put((long)i,new AVM2Instruction(i,AVM2Instructions.Nop,null));
  }
  long startPos=ais.getPosition();
  addresses.add(startPos);
  if (body != null) {
    for (    ABCException e : body.exceptions) {
      addresses.add((long)e.start);
      addresses.add((long)e.end);
      addresses.add((long)e.target);
    }
  }
  loopaddr:   while (!addresses.isEmpty() || !switchAddresses.isEmpty() || !unAdresses.isEmpty()) {
    long address;
    boolean isSwitch=false;
    boolean handleJumps=true;
    if (!addresses.isEmpty()) {
      address=addresses.remove(0);
    }
 else     if (!switchAddresses.isEmpty()) {
      address=switchAddresses.remove(0);
      isSwitch=true;
    }
 else {
      address=unAdresses.remove(0);
      handleJumps=false;
    }
    if (address < startPos) {
      continue;
    }
    try {
      ais.seek(address);
      while (ais.available() > 0) {
        DumpInfo di=ais.newDumpLevel("String_Node_Str","String_Node_Str");
        long startOffset=ais.getPosition();
        if (codeMap.containsKey(startOffset) && !(codeMap.get(startOffset).definition instanceof NopIns)) {
          continue loopaddr;
        }
        int instructionCode=ais.read("String_Node_Str");
        InstructionDefinition instr=instructionSet[instructionCode];
        if (instructionCode == AVM2Instructions.LookupSwitch) {
          if (!isSwitch) {
            switchAddresses.add(startOffset);
            continue loopaddr;
          }
 else {
            isSwitch=false;
          }
        }
        if (di != null) {
          di.name=instr.instructionName;
        }
        if (instr != null) {
          int[] actualOperands=null;
          if (instructionCode == AVM2Instructions.LookupSwitch) {
            int firstOperand=ais.readS24("String_Node_Str");
            int case_count=ais.readU30("String_Node_Str");
            long afterCasePos=ais.getPosition() + 3 * (case_count + 1);
            boolean invalidSwitch=false;
            for (long a=startOffset; a < afterCasePos; a++) {
              if (codeMap.containsKey(a) && (!(codeMap.get(a).definition instanceof NopIns))) {
                invalidSwitch=true;
                break;
              }
            }
            long totalBytes=ais.getPosition() + ais.available();
            if (afterCasePos > totalBytes) {
              invalidSwitch=true;
            }
            if (invalidSwitch) {
              continue loopaddr;
            }
 else {
              actualOperands=new int[case_count + 3];
              actualOperands[0]=firstOperand;
              actualOperands[1]=case_count;
              for (int c=0; c < case_count + 1; c++) {
                actualOperands[2 + c]=ais.readS24("String_Node_Str");
              }
            }
          }
 else {
            if (instr.operands.length > 0) {
              actualOperands=new int[instr.operands.length];
              for (int op=0; op < instr.operands.length; op++) {
switch (instr.operands[op] & 0xff00) {
case OPT_U30:
                  actualOperands[op]=ais.readU30("String_Node_Str");
                break;
case OPT_U8:
              actualOperands[op]=ais.read("String_Node_Str");
            break;
case OPT_BYTE:
          actualOperands[op]=(byte)ais.read("String_Node_Str");
        break;
case OPT_S24:
      actualOperands[op]=ais.readS24("String_Node_Str");
    break;
}
}
}
}
AVM2Instruction ai=new AVM2Instruction(startOffset,instr,actualOperands);
long endOffset=ais.getPosition();
boolean hasRoom=true;
for (long p=startOffset; p < endOffset; p++) {
if (codeMap.containsKey(p) && !(codeMap.get(p).definition instanceof NopIns)) {
hasRoom=false;
}
}
if (!hasRoom) {
continue loopaddr;
}
for (long p=startOffset; p < endOffset; p++) {
codeMap.put(p,ai);
}
ais.endDumpLevel(instr.instructionCode);
if ((instr instanceof IfTypeIns)) {
if (handleJumps) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
}
 else {
actualOperands[0]=0;
}
}
if (instr instanceof JumpIns) {
if (handleJumps) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
unAdresses.add(ais.getPosition());
continue loopaddr;
}
 else {
actualOperands[0]=0;
}
}
if (instr.isExitInstruction()) {
if (handleJumps) {
unAdresses.add(ais.getPosition());
continue loopaddr;
}
}
if (instr instanceof LookupSwitchIns) {
if (handleJumps) {
addresses.add(startOffset + actualOperands[0]);
for (int c=2; c < actualOperands.length; c++) {
addresses.add(startOffset + actualOperands[c]);
}
unAdresses.add(ais.getPosition());
continue loopaddr;
}
 else {
int swlen=(int)(endOffset - startOffset);
actualOperands[0]=swlen;
for (int c=2; c < actualOperands.length; c++) {
actualOperands[c]=swlen;
}
}
}
}
 else {
ais.endDumpLevel();
break;
}
}
}
 catch (EndOfStreamException ex) {
ais.endDumpLevelUntil(diParent);
}
}
AVM2Instruction prev=null;
for (int i=0; i < availableBytes; i++) {
AVM2Instruction ins=codeMap.get((long)i);
if (prev != ins) {
code.add(ins);
}
prev=ins;
}
}

Fixed version (ground truth):
public AVM2Code(ABCInputStream ais,MethodBody body) throws IOException {
  Map<Long,AVM2Instruction> codeMap=new HashMap<>();
  DumpInfo diParent=ais.dumpInfo;
  List<Long> addresses=new ArrayList<>();
  List<Long> unAdresses=new ArrayList<>();
  List<Long> switchAddresses=new ArrayList<>();
  int availableBytes=ais.available();
  for (int i=0; i < availableBytes; i++) {
    codeMap.put((long)i,new AVM2Instruction(i,AVM2Instructions.Nop,null));
  }
  long startPos=ais.getPosition();
  addresses.add(startPos);
  if (body != null) {
    for (    ABCException e : body.exceptions) {
      addresses.add((long)e.start);
      addresses.add((long)e.end);
      addresses.add((long)e.target);
    }
  }
  loopaddr:   while (!addresses.isEmpty() || !switchAddresses.isEmpty() || !unAdresses.isEmpty()) {
    long address;
    boolean isSwitch=false;
    boolean handleJumps=true;
    if (!addresses.isEmpty()) {
      address=addresses.remove(0);
    }
 else     if (!switchAddresses.isEmpty()) {
      address=switchAddresses.remove(0);
      isSwitch=true;
    }
 else {
      address=unAdresses.remove(0);
      handleJumps=false;
    }
    if (address < startPos) {
      continue;
    }
    try {
      ais.seek(address);
      while (ais.available() > 0) {
        DumpInfo di=ais.newDumpLevel("String_Node_Str","String_Node_Str");
        long startOffset=ais.getPosition();
        if (codeMap.containsKey(startOffset) && !(codeMap.get(startOffset).definition instanceof NopIns)) {
          continue loopaddr;
        }
        int instructionCode=ais.read("String_Node_Str");
        InstructionDefinition instr=instructionSet[instructionCode];
        if (instructionCode == AVM2Instructions.LookupSwitch) {
          if (!isSwitch) {
            switchAddresses.add(startOffset);
            continue loopaddr;
          }
 else {
            isSwitch=false;
          }
        }
        if (di != null) {
          di.name=instr.instructionName;
        }
        if (instr != null) {
          int[] actualOperands=null;
          if (instructionCode == AVM2Instructions.LookupSwitch) {
            int firstOperand=ais.readS24("String_Node_Str");
            int case_count=ais.readU30("String_Node_Str");
            long afterCasePos=ais.getPosition() + 3 * (case_count + 1);
            boolean invalidSwitch=false;
            for (long a=startOffset; a < afterCasePos; a++) {
              if (codeMap.containsKey(a) && (!(codeMap.get(a).definition instanceof NopIns))) {
                invalidSwitch=true;
                break;
              }
            }
            long totalBytes=ais.getPosition() + ais.available();
            if (afterCasePos > totalBytes) {
              invalidSwitch=true;
            }
            if (invalidSwitch) {
              continue loopaddr;
            }
 else {
              actualOperands=new int[case_count + 3];
              actualOperands[0]=firstOperand;
              actualOperands[1]=case_count;
              for (int c=0; c < case_count + 1; c++) {
                actualOperands[2 + c]=ais.readS24("String_Node_Str");
              }
            }
          }
 else {
            if (instr.operands.length > 0) {
              actualOperands=new int[instr.operands.length];
              for (int op=0; op < instr.operands.length; op++) {
switch (instr.operands[op] & 0xff00) {
case OPT_U30:
                  actualOperands[op]=ais.readU30("String_Node_Str");
                break;
case OPT_U30_SHORT:
              actualOperands[op]=(short)ais.readU30("String_Node_Str");
            break;
case OPT_U8:
          actualOperands[op]=ais.read("String_Node_Str");
        break;
case OPT_BYTE:
      actualOperands[op]=(byte)ais.read("String_Node_Str");
    break;
case OPT_S24:
  actualOperands[op]=ais.readS24("String_Node_Str");
break;
}
}
}
}
AVM2Instruction ai=new AVM2Instruction(startOffset,instr,actualOperands);
long endOffset=ais.getPosition();
boolean hasRoom=true;
for (long p=startOffset; p < endOffset; p++) {
if (codeMap.containsKey(p) && !(codeMap.get(p).definition instanceof NopIns)) {
hasRoom=false;
}
}
if (!hasRoom) {
continue loopaddr;
}
for (long p=startOffset; p < endOffset; p++) {
codeMap.put(p,ai);
}
ais.endDumpLevel(instr.instructionCode);
if ((instr instanceof IfTypeIns)) {
if (handleJumps) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
}
 else {
actualOperands[0]=0;
}
}
if (instr instanceof JumpIns) {
if (handleJumps) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
unAdresses.add(ais.getPosition());
continue loopaddr;
}
 else {
actualOperands[0]=0;
}
}
if (instr.isExitInstruction()) {
if (handleJumps) {
unAdresses.add(ais.getPosition());
continue loopaddr;
}
}
if (instr instanceof LookupSwitchIns) {
if (handleJumps) {
addresses.add(startOffset + actualOperands[0]);
for (int c=2; c < actualOperands.length; c++) {
addresses.add(startOffset + actualOperands[c]);
}
unAdresses.add(ais.getPosition());
continue loopaddr;
}
 else {
int swlen=(int)(endOffset - startOffset);
actualOperands[0]=swlen;
for (int c=2; c < actualOperands.length; c++) {
actualOperands[c]=swlen;
}
}
}
}
 else {
ais.endDumpLevel();
break;
}
}
}
 catch (EndOfStreamException ex) {
ais.endDumpLevelUntil(diParent);
}
}
AVM2Instruction prev=null;
for (int i=0; i < availableBytes; i++) {
AVM2Instruction ins=codeMap.get((long)i);
if (prev != ins) {
code.add(ins);
}
prev=ins;
}
}