Program: 18433
Project: 18433
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 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 cur=entries.get(minx);
    Entry next=entries.get(minx + 1);
    Entry prev=entries.get(minx);
    Entry prevPrev=entries.get(minx);
    cubicPath.moveTo(cur.getXIndex(),cur.getVal() * phaseY);
    prevDx=(next.getXIndex() - cur.getXIndex()) * intensity;
    prevDy=(next.getVal() - cur.getVal()) * intensity;
    cur=entries.get(minx + 1);
    next=entries.get(minx + (entries.size() - minx > 2 ? 2 : 1));
    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);
    for (int j=minx + 2, count=Math.min(size,entries.size() - 1); j < count; j++) {
      prevPrev=entries.get(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);
  Entry entryTo=dataSet.getEntryForXIndex(mMaxX);
  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);
}