Program: 18445
Project: 18445
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=dataSet.getEntryPosition(entryFrom);
  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);
  minx=Math.max(minx - 2,0);
  size=Math.min(size + 2,entries.size());
  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 + (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; j < size - 1; 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) {
      cur=entries.get(entries.size() - 1);
      prev=entries.get(entries.size() - 2);
      prevPrev=entries.get((entries.size() >= 3) ? entries.size() - 3 : entries.size() - 2);
      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,minx,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=dataSet.getEntryPosition(entryFrom);
  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);
  minx=Math.max(minx - 2,0);
  size=Math.min(size + 2,entries.size());
  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 + (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; j < size - 1; 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) {
      cur=entries.get(entries.size() - 1);
      prev=entries.get(entries.size() - 2);
      prevPrev=entries.get((entries.size() >= 3) ? entries.size() - 3 : entries.size() - 2);
      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);
}