Program: 11033
Project: 11033
Buggy source:
/** 
 * Build a   {@link FastShape} object from the list of binary triangle treeleaves.
 * @param triangles Triangle list.
 * @return FastShape containing triangles from the provided triangle list.
 */
protected FastShape buildFastShape(List<BTTTriangle> triangles){
  List<Position> positions=new ArrayList<Position>();
  List<Integer> originalIndices=new ArrayList<Integer>();
  Map<Position,Integer> positionIndexMap=new HashMap<Position,Integer>();
  int[] indices=new int[triangles.size() * 3];
  int i=0;
  for (  BTTTriangle triangle : triangles) {
    Position apexPosition=this.positions.get(triangle.apexIndex);
    Position leftPosition=this.positions.get(triangle.leftIndex);
    Position rightPosition=this.positions.get(triangle.rightIndex);
    Integer apexIndex=positionIndexMap.get(apexPosition);
    Integer leftIndex=positionIndexMap.get(leftPosition);
    Integer rightIndex=positionIndexMap.get(rightPosition);
    if (apexIndex == null) {
      apexIndex=positions.size();
      positionIndexMap.put(apexPosition,apexIndex);
      positions.add(apexPosition);
      originalIndices.add(triangle.apexIndex);
    }
    if (leftIndex == null) {
      leftIndex=positions.size();
      positionIndexMap.put(leftPosition,leftIndex);
      positions.add(leftPosition);
      originalIndices.add(triangle.leftIndex);
    }
    if (rightIndex == null) {
      rightIndex=positions.size();
      positionIndexMap.put(rightPosition,rightIndex);
      positions.add(rightPosition);
      originalIndices.add(triangle.rightIndex);
    }
    indices[i++]=leftIndex;
    indices[i++]=rightIndex;
  }
  FastShape shape=new FastShape(positions,indices,GL.GL_TRIANGLES);
  if (generateTextureCoordinates) {
    float[] textureCoordinateBuffer=new float[positions.size() * 2];
    i=0;
    for (    Integer index : originalIndices) {
      int x=index % width;
      int y=index / width;
      textureCoordinateBuffer[i++]=x / (float)(width - 1);
      textureCoordinateBuffer[i++]=y / (float)(height - 1);
    }
    shape.setTextureCoordinateBuffer(textureCoordinateBuffer);
  }
  return shape;
}

Fixed version (ground truth):
/** 
 * Build a   {@link FastShape} object from the list of binary triangle treeleaves.
 * @param triangles Triangle list.
 * @return FastShape containing triangles from the provided triangle list.
 */
protected FastShape buildFastShape(List<BTTTriangle> triangles){
  List<Position> positions=new ArrayList<Position>();
  List<Integer> originalIndices=new ArrayList<Integer>();
  Map<Position,Integer> positionIndexMap=new HashMap<Position,Integer>();
  int[] indices=new int[triangles.size() * 3];
  int i=0;
  for (  BTTTriangle triangle : triangles) {
    Position apexPosition=this.positions.get(triangle.apexIndex);
    Position leftPosition=this.positions.get(triangle.leftIndex);
    Position rightPosition=this.positions.get(triangle.rightIndex);
    Integer apexIndex=positionIndexMap.get(apexPosition);
    Integer leftIndex=positionIndexMap.get(leftPosition);
    Integer rightIndex=positionIndexMap.get(rightPosition);
    if (apexIndex == null) {
      apexIndex=positions.size();
      positionIndexMap.put(apexPosition,apexIndex);
      positions.add(apexPosition);
      originalIndices.add(triangle.apexIndex);
    }
    if (leftIndex == null) {
      leftIndex=positions.size();
      positionIndexMap.put(leftPosition,leftIndex);
      positions.add(leftPosition);
      originalIndices.add(triangle.leftIndex);
    }
    if (rightIndex == null) {
      rightIndex=positions.size();
      positionIndexMap.put(rightPosition,rightIndex);
      positions.add(rightPosition);
      originalIndices.add(triangle.rightIndex);
    }
    indices[i++]=leftIndex;
    indices[i++]=apexIndex;
    indices[i++]=rightIndex;
  }
  FastShape shape=new FastShape(positions,indices,GL.GL_TRIANGLES);
  if (generateTextureCoordinates) {
    float[] textureCoordinateBuffer=new float[positions.size() * 2];
    i=0;
    for (    Integer index : originalIndices) {
      int x=index % width;
      int y=index / width;
      textureCoordinateBuffer[i++]=x / (float)(width - 1);
      textureCoordinateBuffer[i++]=y / (float)(height - 1);
    }
    shape.setTextureCoordinateBuffer(textureCoordinateBuffer);
  }
  return shape;
}