Program: 18357
Project: 18357
Buggy source:
protected void drawDataSet(Canvas c,CandleDataSet dataSet){
  Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
  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=Math.max(dataSet.getEntryPosition(entryFrom),0);
  int maxx=Math.min(dataSet.getEntryPosition(entryTo) + 1,entries.size());
  int range=(maxx - minx) * 4;
  int to=(int)Math.ceil((maxx - minx) * phaseX + minx);
  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);
  CandleShadowBuffer shadowBuffer=mShadowBuffers[dataSetIndex];
  shadowBuffer.setPhases(phaseX,phaseY);
  shadowBuffer.limitFrom(minx);
  shadowBuffer.limitTo(maxx);
  shadowBuffer.feed(entries);
  trans.pointValuesToPixel(shadowBuffer.buffer);
  mRenderPaint.setStrokeWidth(dataSet.getShadowWidth());
  for (int j=0; j < range; j+=4) {
    CandleEntry e=entries.get(j / 4 + minx);
    if (!fitsBounds(e.getXIndex(),mMinX,to))     continue;
    if (dataSet.getShadowColorSameAsCandle()) {
      if (e.getOpen() > e.getClose())       mRenderPaint.setColor(dataSet.getDecreasingColor() == ColorTemplate.COLOR_NONE ? dataSet.getColor(j) : dataSet.getDecreasingColor());
 else       if (e.getOpen() < e.getClose())       mRenderPaint.setColor(dataSet.getIncreasingColor() == ColorTemplate.COLOR_NONE ? dataSet.getColor(j) : dataSet.getIncreasingColor());
 else       mRenderPaint.setColor(dataSet.getShadowColor() == ColorTemplate.COLOR_NONE ? dataSet.getColor(j) : dataSet.getShadowColor());
    }
 else {
      mRenderPaint.setColor(dataSet.getShadowColor() == ColorTemplate.COLOR_NONE ? dataSet.getColor(j) : dataSet.getShadowColor());
    }
    mRenderPaint.setStyle(Paint.Style.STROKE);
    c.drawLine(shadowBuffer.buffer[j],shadowBuffer.buffer[j + 1],shadowBuffer.buffer[j + 2],shadowBuffer.buffer[j + 3],mRenderPaint);
    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(dataSet.getShadowColor());
      c.drawLine(leftBody,open,rightBody,close,mRenderPaint);
    }
  }
}

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