Program: 18279
Project: 18279
Buggy source:
/** 
 * Draws a cubic line.
 * @param c
 * @param dataSet
 * @param entries
 */
protected void drawCubic(Canvas c,LineDataSet dataSet,List<Entry> entries){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  Entry entryFrom=dataSet.getEntryForXIndex(mMinX);
  Entry entryTo=dataSet.getEntryForXIndex(mMaxX);
  int diff=(entryFrom == entryTo) ? 1 : 0;
  int minx=Math.max(dataSet.getEntryPosition(entryFrom) - diff,0);
  int maxx=Math.min(Math.max(minx + 2,dataSet.getEntryPosition(entryTo) + 1),entries.size());
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  float intensity=dataSet.getCubicIntensity();
  cubicPath.reset();
  int size=(int)Math.ceil((maxx - minx) * phaseX + minx);
  if (size - minx >= 2) {
    float prevDx=0f;
    float prevDy=0f;
    float curDx=0f;
    float curDy=0f;
    Entry prevPrev=entries.get(minx);
    Entry prev=entries.get(minx);
    Entry cur=entries.get(minx);
    Entry next=entries.get(minx + 1);
    cubicPath.moveTo(cur.getXIndex(),cur.getVal() * phaseY);
    prevDx=(cur.getXIndex() - prev.getXIndex()) * intensity;
    prevDy=(cur.getVal() - prev.getVal()) * intensity;
    curDx=(next.getXIndex() - cur.getXIndex()) * intensity;
    curDy=(next.getVal() - cur.getVal()) * intensity;
    cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    for (int j=minx + 1, count=Math.min(size,entries.size() - 1); j < count; j++) {
      prevPrev=entries.get(j == 1 ? 0 : j - 2);
      prev=entries.get(j - 1);
      cur=entries.get(j);
      next=entries.get(j + 1);
      prevDx=(cur.getXIndex() - prevPrev.getXIndex()) * intensity;
      prevDy=(cur.getVal() - prevPrev.getVal()) * intensity;
      curDx=(next.getXIndex() - prev.getXIndex()) * intensity;
      curDy=(next.getVal() - prev.getVal()) * intensity;
      cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    }
    if (size > entries.size() - 1) {
      prevPrev=entries.get((entries.size() >= 3) ? entries.size() - 3 : entries.size() - 2);
      prev=entries.get(entries.size() - 2);
      cur=entries.get(entries.size() - 1);
      next=cur;
      prevDx=(cur.getXIndex() - prevPrev.getXIndex()) * intensity;
      prevDy=(cur.getVal() - prevPrev.getVal()) * intensity;
      curDx=(next.getXIndex() - prev.getXIndex()) * intensity;
      curDy=(next.getVal() - prev.getVal()) * intensity;
      cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    }
  }
  if (dataSet.isDrawFilledEnabled()) {
    cubicFillPath.reset();
    cubicFillPath.addPath(cubicPath);
    drawCubicFill(mBitmapCanvas,dataSet,cubicFillPath,trans,entryFrom.getXIndex(),entryFrom.getXIndex() + size);
  }
  mRenderPaint.setColor(dataSet.getColor());
  mRenderPaint.setStyle(Paint.Style.STROKE);
  trans.pathValueToPixel(cubicPath);
  mBitmapCanvas.drawPath(cubicPath,mRenderPaint);
  mRenderPaint.setPathEffect(null);
}

Fixed version (ground truth):
/** 
 * Draws a cubic line.
 * @param c
 * @param dataSet
 * @param entries
 */
protected void drawCubic(Canvas c,LineDataSet dataSet,List<Entry> entries){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  Entry entryFrom=dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX,DataSet.Rounding.DOWN);
  Entry entryTo=dataSet.getEntryForXIndex(mMaxX,DataSet.Rounding.UP);
  int minx=Math.max(dataSet.getEntryPosition(entryFrom),0);
  int maxx=Math.min(dataSet.getEntryPosition(entryTo) + 1,entries.size());
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  float intensity=dataSet.getCubicIntensity();
  cubicPath.reset();
  int size=(int)Math.ceil((maxx - minx) * phaseX + minx);
  if (size - minx >= 2) {
    float prevDx=0f;
    float prevDy=0f;
    float curDx=0f;
    float curDy=0f;
    Entry prevPrev=entries.get(minx);
    Entry prev=entries.get(minx);
    Entry cur=entries.get(minx);
    Entry next=entries.get(minx + 1);
    cubicPath.moveTo(cur.getXIndex(),cur.getVal() * phaseY);
    prevDx=(cur.getXIndex() - prev.getXIndex()) * intensity;
    prevDy=(cur.getVal() - prev.getVal()) * intensity;
    curDx=(next.getXIndex() - cur.getXIndex()) * intensity;
    curDy=(next.getVal() - cur.getVal()) * intensity;
    cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    for (int j=minx + 1, count=Math.min(size,entries.size() - 1); j < count; j++) {
      prevPrev=entries.get(j == 1 ? 0 : j - 2);
      prev=entries.get(j - 1);
      cur=entries.get(j);
      next=entries.get(j + 1);
      prevDx=(cur.getXIndex() - prevPrev.getXIndex()) * intensity;
      prevDy=(cur.getVal() - prevPrev.getVal()) * intensity;
      curDx=(next.getXIndex() - prev.getXIndex()) * intensity;
      curDy=(next.getVal() - prev.getVal()) * intensity;
      cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    }
    if (size > entries.size() - 1) {
      prevPrev=entries.get((entries.size() >= 3) ? entries.size() - 3 : entries.size() - 2);
      prev=entries.get(entries.size() - 2);
      cur=entries.get(entries.size() - 1);
      next=cur;
      prevDx=(cur.getXIndex() - prevPrev.getXIndex()) * intensity;
      prevDy=(cur.getVal() - prevPrev.getVal()) * intensity;
      curDx=(next.getXIndex() - prev.getXIndex()) * intensity;
      curDy=(next.getVal() - prev.getVal()) * intensity;
      cubicPath.cubicTo(prev.getXIndex() + prevDx,(prev.getVal() + prevDy) * phaseY,cur.getXIndex() - curDx,(cur.getVal() - curDy) * phaseY,cur.getXIndex(),cur.getVal() * phaseY);
    }
  }
  if (dataSet.isDrawFilledEnabled()) {
    cubicFillPath.reset();
    cubicFillPath.addPath(cubicPath);
    drawCubicFill(mBitmapCanvas,dataSet,cubicFillPath,trans,entryFrom.getXIndex(),entryFrom.getXIndex() + size);
  }
  mRenderPaint.setColor(dataSet.getColor());
  mRenderPaint.setStyle(Paint.Style.STROKE);
  trans.pathValueToPixel(cubicPath);
  mBitmapCanvas.drawPath(cubicPath,mRenderPaint);
  mRenderPaint.setPathEffect(null);
}