Program: 154068
Project: 154068
Buggy source:
/** 
 * Perform scan conversion of a convex polygon.
 * @param rectList A <code>LinkedList</code>; may be null.
 * @return A <code>LinkedList</code> of <code>Rectangle</code>srepresenting the scan conversion of the convex polygon.
 */
private LinkedList scanConvex(LinkedList rectList){
  if (rectList == null) {
    rectList=new LinkedList();
  }
  int yMin=poly.ypoints[0];
  int topVertex=0;
  int n=poly.npoints;
  for (int i=1; i < n; i++) {
    if (poly.ypoints[i] < yMin) {
      yMin=poly.ypoints[i];
      topVertex=i;
    }
  }
  int leftIndex=topVertex;
  int rightIndex=topVertex;
  int numRemaining=n;
  int y=yMin;
  int intYLeft=y - 1;
  int intYRight=intYLeft;
  double[] px=intArrayToDoubleArray(poly.xpoints);
  int[] py=poly.ypoints;
  double[] leftX=new double[1];
  double[] leftDX=new double[1];
  double[] rightX=new double[1];
  double[] rightDX=new double[1];
  while (numRemaining > 0) {
    int i;
    while (intYLeft <= y && numRemaining > 0) {
      numRemaining--;
      i=leftIndex - 1;
      if (i < 0)       i=n - 1;
      intersectX(px[leftIndex],py[leftIndex],px[i],py[i],y,leftX,leftDX);
      intYLeft=py[i];
      leftIndex=i;
    }
    while (intYRight <= y && numRemaining > 0) {
      numRemaining--;
      i=rightIndex + 1;
      if (i >= n)       i=0;
      intersectX(px[rightIndex],py[rightIndex],px[i],py[i],y,rightX,rightDX);
      intYRight=py[i];
      rightIndex=i;
    }
    while (y < intYLeft && y < intYRight) {
      if (y >= clip.y && y <= clip.getMaxY()) {
        Rectangle rect;
        if (leftX[0] <= rightX[0]) {
          rect=scanSegment(y,leftX[0],rightX[0]);
        }
 else {
          rect=scanSegment(y,rightX[0],leftX[0]);
        }
        if (rect != null) {
          rectList.addLast((Object)rect);
        }
      }
      y++;
      leftX[0]+=leftDX[0];
      rightX[0]+=rightDX[0];
    }
  }
  return rectList;
}

Fixed version (ground truth):
/** 
 * Perform scan conversion of a convex polygon.
 * @param rectList A <code>LinkedList</code>; may be null.
 * @return A <code>LinkedList</code> of <code>Rectangle</code>srepresenting the scan conversion of the convex polygon.
 */
private LinkedList scanConvex(LinkedList rectList){
  if (rectList == null) {
    rectList=new LinkedList();
  }
  int yMin=poly.ypoints[0];
  int topVertex=0;
  int n=poly.npoints;
  for (int i=1; i < n; i++) {
    if (poly.ypoints[i] < yMin) {
      yMin=poly.ypoints[i];
      topVertex=i;
    }
  }
  int leftIndex=topVertex;
  int rightIndex=topVertex;
  int numRemaining=n;
  int y=yMin;
  int intYLeft=y - 1;
  int intYRight=intYLeft;
  double[] px=intArrayToDoubleArray(poly.xpoints);
  int[] py=poly.ypoints;
  double[] leftX=new double[1];
  double[] leftDX=new double[1];
  double[] rightX=new double[1];
  double[] rightDX=new double[1];
  while (numRemaining > 0) {
    int i;
    while (intYLeft <= y && numRemaining > 0) {
      numRemaining--;
      i=leftIndex - 1;
      if (i < 0)       i=n - 1;
      intersectX(px[leftIndex],py[leftIndex],px[i],py[i],y,leftX,leftDX);
      intYLeft=py[i];
      leftIndex=i;
    }
    while (intYRight <= y && numRemaining > 0) {
      numRemaining--;
      i=rightIndex + 1;
      if (i >= n)       i=0;
      intersectX(px[rightIndex],py[rightIndex],px[i],py[i],y,rightX,rightDX);
      intYRight=py[i];
      rightIndex=i;
    }
    while (y < intYLeft && y < intYRight) {
      if (y >= clip.y && y < clip.getMaxY()) {
        Rectangle rect;
        if (leftX[0] <= rightX[0]) {
          rect=scanSegment(y,leftX[0],rightX[0]);
        }
 else {
          rect=scanSegment(y,rightX[0],leftX[0]);
        }
        if (rect != null) {
          rectList.addLast((Object)rect);
        }
      }
      y++;
      leftX[0]+=leftDX[0];
      rightX[0]+=rightDX[0];
    }
  }
  return rectList;
}