Program: 85810
Project: 85810
Buggy source:
/** 
 * <p>To run a script, first we parse it which breaks it up into chunks representing pushes of data or logical opcodes. Then we can run the parsed chunks.</p> <p>The reason for this split, instead of just interpreting directly, is to make it easier to reach into a programs structure and pull out bits of data without having to run it. This is necessary to render the to/from addresses of transactions in a user interface. The official client does something similar.</p>
 */
private void parse(byte[] program) throws ScriptException {
  chunks=new ArrayList<ScriptChunk>(10);
  ByteArrayInputStream bis=new ByteArrayInputStream(program);
  int initialSize=bis.available();
  while (bis.available() > 0) {
    int startLocationInProgram=initialSize - bis.available();
    int opcode=bis.read();
    long dataToRead=-1;
    if (opcode >= 0 && opcode < OP_PUSHDATA1) {
      dataToRead=opcode;
    }
 else     if (opcode == OP_PUSHDATA1) {
      if (bis.available() < 1)       throw new ScriptException("String_Node_Str");
      dataToRead=bis.read();
    }
 else     if (opcode == OP_PUSHDATA2) {
      if (bis.available() < 2)       throw new ScriptException("String_Node_Str");
      dataToRead=bis.read() | (bis.read() << 8);
    }
 else     if (opcode == OP_PUSHDATA4) {
      if (bis.available() < 4)       throw new ScriptException("String_Node_Str");
      dataToRead=bis.read() | (bis.read() << 8) | (bis.read() << 16)| (bis.read() << 24);
    }
    if (dataToRead == -1) {
      chunks.add(new ScriptChunk(true,new byte[]{(byte)opcode},startLocationInProgram));
    }
 else {
      if (dataToRead > MAX_SCRIPT_ELEMENT_SIZE)       throw new ScriptException("String_Node_Str");
      byte[] data=new byte[(int)dataToRead];
      if (dataToRead > 0 && bis.read(data,0,(int)dataToRead) < dataToRead)       throw new ScriptException("String_Node_Str");
      chunks.add(new ScriptChunk(false,data,startLocationInProgram));
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>To run a script, first we parse it which breaks it up into chunks representing pushes of data or logical opcodes. Then we can run the parsed chunks.</p> <p>The reason for this split, instead of just interpreting directly, is to make it easier to reach into a programs structure and pull out bits of data without having to run it. This is necessary to render the to/from addresses of transactions in a user interface. The official client does something similar.</p>
 */
private void parse(byte[] program) throws ScriptException {
  chunks=new ArrayList<ScriptChunk>(10);
  ByteArrayInputStream bis=new ByteArrayInputStream(program);
  int initialSize=bis.available();
  while (bis.available() > 0) {
    int startLocationInProgram=initialSize - bis.available();
    int opcode=bis.read();
    long dataToRead=-1;
    if (opcode >= 0 && opcode < OP_PUSHDATA1) {
      dataToRead=opcode;
    }
 else     if (opcode == OP_PUSHDATA1) {
      if (bis.available() < 1)       throw new ScriptException("String_Node_Str");
      dataToRead=bis.read();
    }
 else     if (opcode == OP_PUSHDATA2) {
      if (bis.available() < 2)       throw new ScriptException("String_Node_Str");
      dataToRead=bis.read() | (bis.read() << 8);
    }
 else     if (opcode == OP_PUSHDATA4) {
      if (bis.available() < 4)       throw new ScriptException("String_Node_Str");
      dataToRead=((long)bis.read()) | (((long)bis.read()) << 8) | (((long)bis.read()) << 16)| (((long)bis.read()) << 24);
    }
    if (dataToRead == -1) {
      chunks.add(new ScriptChunk(true,new byte[]{(byte)opcode},startLocationInProgram));
    }
 else {
      if (dataToRead > bis.available())       throw new ScriptException("String_Node_Str");
      byte[] data=new byte[(int)dataToRead];
      checkState(dataToRead == 0 || bis.read(data,0,(int)dataToRead) == dataToRead);
      chunks.add(new ScriptChunk(false,data,startLocationInProgram));
    }
  }
}