Program: 87840
Project: 87840
Buggy source:
/** 
 * Draw gesture preview trail
 * @param canvas The canvas to draw the gesture preview trail
 * @param paint The paint object to be used to draw the gesture preview trail
 * @param outBoundsRect the bounding box of this gesture trail drawing
 * @param params The drawing parameters of gesture preview trail
 * @return true if some gesture preview trails remain to be drawn
 */
public boolean drawGestureTrail(final Canvas canvas,final Paint paint,final Rect outBoundsRect,final Params params){
  final int trailSize=mEventTimes.getLength();
  if (trailSize == 0) {
    return false;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int[] xCoords=mXCoordinates.getPrimitiveArray();
  final int[] yCoords=mYCoordinates.getPrimitiveArray();
  final int sinceDown=(int)(SystemClock.uptimeMillis() - mCurrentTimeBase);
  int startIndex;
  for (startIndex=mTrailStartIndex; startIndex < trailSize; startIndex++) {
    final int elapsedTime=sinceDown - eventTimes[startIndex];
    if (elapsedTime < params.mTrailLingerDuration) {
      break;
    }
  }
  mTrailStartIndex=startIndex;
  if (startIndex < trailSize) {
    paint.setColor(params.mTrailColor);
    paint.setStyle(Paint.Style.FILL);
    final RoundedLine line=mRoundedLine;
    int p1x=getXCoordValue(xCoords[startIndex]);
    int p1y=yCoords[startIndex];
    int lastTime=sinceDown - eventTimes[startIndex];
    float maxWidth=getWidth(lastTime,params);
    float r1=maxWidth / 2.0f;
    outBoundsRect.set(p1x,p1y,p1x,p1y);
    for (int i=startIndex + 1; i < trailSize - 1; i++) {
      final int elapsedTime=sinceDown - eventTimes[i];
      final int p2x=getXCoordValue(xCoords[i]);
      final int p2y=yCoords[i];
      final float width=getWidth(elapsedTime,params);
      final float r2=width / 2.0f;
      if (!isDownEventXCoord(xCoords[i])) {
        final int alpha=getAlpha(elapsedTime,params);
        paint.setAlpha(alpha);
        final Path path=line.makePath(p1x,p1y,r1,p2x,p2y,r2);
        if (path != null) {
          canvas.drawPath(path,paint);
          outBoundsRect.union(p2x,p2y);
        }
        maxWidth=Math.max(maxWidth,width);
      }
      p1x=p2x;
      p1y=p2y;
      r1=r2;
      lastTime=elapsedTime;
    }
    final int inset=-((int)maxWidth + 1);
    outBoundsRect.inset(inset,inset);
  }
  final int newSize=trailSize - startIndex;
  if (newSize < startIndex) {
    mTrailStartIndex=0;
    if (newSize > 0) {
      System.arraycopy(eventTimes,startIndex,eventTimes,0,newSize);
      System.arraycopy(xCoords,startIndex,xCoords,0,newSize);
      System.arraycopy(yCoords,startIndex,yCoords,0,newSize);
    }
    mEventTimes.setLength(newSize);
    mXCoordinates.setLength(newSize);
    mYCoordinates.setLength(newSize);
  }
  return newSize > 0;
}

Fixed version (ground truth):
/** 
 * Draw gesture preview trail
 * @param canvas The canvas to draw the gesture preview trail
 * @param paint The paint object to be used to draw the gesture preview trail
 * @param outBoundsRect the bounding box of this gesture trail drawing
 * @param params The drawing parameters of gesture preview trail
 * @return true if some gesture preview trails remain to be drawn
 */
public boolean drawGestureTrail(final Canvas canvas,final Paint paint,final Rect outBoundsRect,final Params params){
  final int trailSize=mEventTimes.getLength();
  if (trailSize == 0) {
    return false;
  }
  final int[] eventTimes=mEventTimes.getPrimitiveArray();
  final int[] xCoords=mXCoordinates.getPrimitiveArray();
  final int[] yCoords=mYCoordinates.getPrimitiveArray();
  final int sinceDown=(int)(SystemClock.uptimeMillis() - mCurrentTimeBase);
  int startIndex;
  for (startIndex=mTrailStartIndex; startIndex < trailSize; startIndex++) {
    final int elapsedTime=sinceDown - eventTimes[startIndex];
    if (elapsedTime < params.mTrailLingerDuration) {
      break;
    }
  }
  mTrailStartIndex=startIndex;
  if (startIndex < trailSize) {
    paint.setColor(params.mTrailColor);
    paint.setStyle(Paint.Style.FILL);
    final RoundedLine line=mRoundedLine;
    int p1x=getXCoordValue(xCoords[startIndex]);
    int p1y=yCoords[startIndex];
    int lastTime=sinceDown - eventTimes[startIndex];
    float maxWidth=getWidth(lastTime,params);
    float r1=maxWidth / 2.0f;
    outBoundsRect.set(p1x,p1y,p1x,p1y);
    for (int i=startIndex + 1; i < trailSize; i++) {
      final int elapsedTime=sinceDown - eventTimes[i];
      final int p2x=getXCoordValue(xCoords[i]);
      final int p2y=yCoords[i];
      final float width=getWidth(elapsedTime,params);
      final float r2=width / 2.0f;
      if (!isDownEventXCoord(xCoords[i])) {
        final int alpha=getAlpha(elapsedTime,params);
        paint.setAlpha(alpha);
        final Path path=line.makePath(p1x,p1y,r1,p2x,p2y,r2);
        if (path != null) {
          canvas.drawPath(path,paint);
          outBoundsRect.union(p2x,p2y);
        }
        maxWidth=Math.max(maxWidth,width);
      }
      p1x=p2x;
      p1y=p2y;
      r1=r2;
      lastTime=elapsedTime;
    }
    final int inset=-((int)maxWidth + 1);
    outBoundsRect.inset(inset,inset);
  }
  final int newSize=trailSize - startIndex;
  if (newSize < startIndex) {
    mTrailStartIndex=0;
    if (newSize > 0) {
      System.arraycopy(eventTimes,startIndex,eventTimes,0,newSize);
      System.arraycopy(xCoords,startIndex,xCoords,0,newSize);
      System.arraycopy(yCoords,startIndex,yCoords,0,newSize);
    }
    mEventTimes.setLength(newSize);
    mXCoordinates.setLength(newSize);
    mYCoordinates.setLength(newSize);
  }
  return newSize > 0;
}