Program: 26551
Project: 26551
Buggy source:
protected void drawDataSet(Canvas c,CandleDataSet dataSet){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  calcXBounds(trans);
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  int dataSetIndex=mChart.getCandleData().getIndexOfDataSet(dataSet);
  List<CandleEntry> entries=dataSet.getYVals();
  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());
  int range=(maxx - minx) * 4;
  int to=(int)Math.ceil((maxx - minx) * phaseX + minx);
  CandleShadowBuffer shadowBuffer=mShadowBuffers[dataSetIndex];
  shadowBuffer.setPhases(phaseX,phaseY);
  shadowBuffer.limitFrom(minx);
  shadowBuffer.limitTo(maxx);
  shadowBuffer.feed(entries);
  trans.pointValuesToPixel(shadowBuffer.buffer);
  mRenderPaint.setStyle(Paint.Style.STROKE);
  if (dataSet.getShadowColor() == ColorTemplate.COLOR_NONE) {
    mRenderPaint.setColor(dataSet.getColor());
  }
 else {
    mRenderPaint.setColor(dataSet.getShadowColor());
  }
  mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
  c.drawLines(shadowBuffer.buffer,0,range,mRenderPaint);
  CandleBodyBuffer bodyBuffer=mBodyBuffers[dataSetIndex];
  bodyBuffer.setBodySpace(dataSet.getBodySpace());
  bodyBuffer.setPhases(phaseX,phaseY);
  bodyBuffer.limitFrom(minx);
  bodyBuffer.limitTo(maxx);
  bodyBuffer.feed(entries);
  trans.pointValuesToPixel(bodyBuffer.buffer);
  for (int j=0; j < range; j+=4) {
    CandleEntry e=entries.get(j / 4 + minx);
    if (!fitsBounds(e.getXIndex(),mMinX,to))     continue;
    float leftBody=bodyBuffer.buffer[j];
    float open=bodyBuffer.buffer[j + 1];
    float rightBody=bodyBuffer.buffer[j + 2];
    float close=bodyBuffer.buffer[j + 3];
    if (open > close) {
      if (dataSet.getDecreasingColor() == ColorTemplate.COLOR_NONE) {
        mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
      }
 else {
        mRenderPaint.setColor(dataSet.getDecreasingColor());
      }
      mRenderPaint.setStyle(dataSet.getDecreasingPaintStyle());
      c.drawRect(leftBody,close,rightBody,open,mRenderPaint);
    }
 else {
      if (dataSet.getIncreasingColor() == ColorTemplate.COLOR_NONE) {
        mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
      }
 else {
        mRenderPaint.setColor(dataSet.getIncreasingColor());
      }
      mRenderPaint.setStyle(dataSet.getIncreasingPaintStyle());
      c.drawRect(leftBody,open,rightBody,close,mRenderPaint);
    }
  }
}

Fixed version (ground truth):
protected void drawDataSet(Canvas c,CandleDataSet dataSet){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  calcXBounds(trans);
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  int dataSetIndex=mChart.getCandleData().getIndexOfDataSet(dataSet);
  List<CandleEntry> entries=dataSet.getYVals();
  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());
  int range=(maxx - minx) * 4;
  int to=(int)Math.ceil((maxx - minx) * phaseX + minx);
  CandleShadowBuffer shadowBuffer=mShadowBuffers[dataSetIndex];
  shadowBuffer.setPhases(phaseX,phaseY);
  shadowBuffer.limitFrom(minx);
  shadowBuffer.limitTo(maxx);
  shadowBuffer.feed(entries);
  trans.pointValuesToPixel(shadowBuffer.buffer);
  mRenderPaint.setStyle(Paint.Style.STROKE);
  if (dataSet.getShadowColor() == ColorTemplate.COLOR_NONE) {
    mRenderPaint.setColor(dataSet.getColor());
  }
 else {
    mRenderPaint.setColor(dataSet.getShadowColor());
  }
  mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
  c.drawLines(shadowBuffer.buffer,0,range,mRenderPaint);
  CandleBodyBuffer bodyBuffer=mBodyBuffers[dataSetIndex];
  bodyBuffer.setBodySpace(dataSet.getBodySpace());
  bodyBuffer.setPhases(phaseX,phaseY);
  bodyBuffer.limitFrom(minx);
  bodyBuffer.limitTo(maxx);
  bodyBuffer.feed(entries);
  trans.pointValuesToPixel(bodyBuffer.buffer);
  for (int j=0; j < range; j+=4) {
    CandleEntry e=entries.get(j / 4 + minx);
    if (!fitsBounds(e.getXIndex(),mMinX,to))     continue;
    float leftBody=bodyBuffer.buffer[j];
    float open=bodyBuffer.buffer[j + 1];
    float rightBody=bodyBuffer.buffer[j + 2];
    float close=bodyBuffer.buffer[j + 3];
    if (open > close) {
      if (dataSet.getDecreasingColor() == ColorTemplate.COLOR_NONE) {
        mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
      }
 else {
        mRenderPaint.setColor(dataSet.getDecreasingColor());
      }
      mRenderPaint.setStyle(dataSet.getDecreasingPaintStyle());
      c.drawRect(leftBody,close,rightBody,open,mRenderPaint);
    }
 else     if (open < close) {
      if (dataSet.getIncreasingColor() == ColorTemplate.COLOR_NONE) {
        mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
      }
 else {
        mRenderPaint.setColor(dataSet.getIncreasingColor());
      }
      mRenderPaint.setStyle(dataSet.getIncreasingPaintStyle());
      c.drawRect(leftBody,open,rightBody,close,mRenderPaint);
    }
 else {
      mRenderPaint.setColor(Color.BLACK);
      mRenderPaint.setStyle(Paint.Style.STROKE);
      c.drawLine(leftBody,open,rightBody,close,mRenderPaint);
    }
  }
}