Program: 61538
Project: 61538
Buggy source:
public AVM2Code(ABCInputStream ais) throws IOException {
  Map<Long,AVM2Instruction> codeMap=new TreeMap<>();
  DumpInfo diParent=ais.dumpInfo;
  List<Long> addresses=new ArrayList<>();
  long startPos=ais.getPosition();
  addresses.add(startPos);
  while (!addresses.isEmpty()) {
    long address=addresses.remove(0);
    boolean afterExit=false;
    if (codeMap.containsKey(address)) {
      continue;
    }
    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();
        int instructionCode=ais.read("String_Node_Str");
        InstructionDefinition instr=instructionSet[instructionCode];
        if (di != null) {
          di.name=instr.instructionName;
        }
        if (instr != null) {
          int[] actualOperands=null;
          if (instructionCode == 0x1b) {
            int firstOperand=ais.readS24("String_Node_Str");
            int case_count=ais.readU30("String_Node_Str");
            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;
}
}
}
}
if (!afterExit && (instr instanceof IfTypeIns)) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
}
codeMap.put(startOffset,new AVM2Instruction(startOffset,instr,actualOperands));
ais.endDumpLevel(instr.instructionCode);
if (instr.isExitInstruction()) {
afterExit=true;
}
}
 else {
ais.endDumpLevel();
break;
}
}
}
 catch (EndOfStreamException ex) {
ais.endDumpLevelUntil(diParent);
}
}
code.addAll(codeMap.values());
}

Fixed version (ground truth):
public AVM2Code(ABCInputStream ais) throws IOException {
  Map<Long,AVM2Instruction> codeMap=new TreeMap<>();
  DumpInfo diParent=ais.dumpInfo;
  List<Long> addresses=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,new NopIns(),new int[]{}));
  }
  long startPos=ais.getPosition();
  addresses.add(startPos);
  loopaddr:   while (!addresses.isEmpty() || !switchAddresses.isEmpty()) {
    long address;
    boolean isSwitch=false;
    if (!addresses.isEmpty()) {
      address=addresses.remove(0);
    }
 else {
      address=switchAddresses.remove(0);
      isSwitch=true;
    }
    if (codeMap.containsKey(address) && !(codeMap.get(address).definition instanceof NopIns)) {
      continue;
    }
    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();
        int instructionCode=ais.read("String_Node_Str");
        InstructionDefinition instr=instructionSet[instructionCode];
        if (instr instanceof LookupSwitchIns) {
          if (!isSwitch) {
            switchAddresses.add(startOffset);
            continue loopaddr;
          }
 else {
            isSwitch=false;
          }
        }
        if (di != null) {
          di.name=instr.instructionName;
        }
        if (instr != null) {
          int[] actualOperands=null;
          long beforeSwitchPos=ais.getPosition();
          if (instructionCode == 0x1b) {
            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=beforeSwitchPos; 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();
for (long p=startOffset; p < endOffset; p++) {
codeMap.put(p,ai);
}
ais.endDumpLevel(instr.instructionCode);
if ((instr instanceof IfTypeIns)) {
long target=ais.getPosition() + actualOperands[0];
addresses.add(target);
}
}
 else {
ais.endDumpLevel();
break;
}
}
}
 catch (EndOfStreamException ex) {
ais.endDumpLevelUntil(diParent);
}
}
AVM2Instruction prev=null;
for (AVM2Instruction ins : codeMap.values()) {
if (prev != ins) {
code.add(ins);
}
prev=ins;
}
}