Program: 26315
Project: 26315
Buggy source:
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  float angle;
  float rotationAngle=mChart.getRotationAngle();
  float[] drawAngles=mChart.getDrawAngles();
  float[] absoluteAngles=mChart.getAbsoluteAngles();
  final PointF center=mChart.getCenterCircleBox();
  final float radius=mChart.getRadius();
  final float userInnerRadius=mChart.isDrawHoleEnabled() && !mChart.isDrawSlicesUnderHoleEnabled() ? radius * (mChart.getHoleRadius() / 100.f) : 0.f;
  final RectF highlightedCircleBox=new RectF();
  for (int i=0; i < indices.length; i++) {
    int xIndex=indices[i].getXIndex();
    if (xIndex >= drawAngles.length)     continue;
    IPieDataSet set=mChart.getData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    final int entryCount=set.getEntryCount();
    int visibleAngleCount=0;
    for (int j=0; j < entryCount; j++) {
      if ((Math.abs(set.getEntryForIndex(j).getVal()) > 0.000001)) {
        visibleAngleCount++;
      }
    }
    if (xIndex == 0)     angle=0.f;
 else     angle=absoluteAngles[xIndex - 1] * phaseX;
    float sliceSpace=set.getSliceSpace();
    float sliceAngle=drawAngles[xIndex];
    final float sliceSpaceOuterAngle=visibleAngleCount == 1 ? 0.f : sliceSpace / (Utils.FDEG2RAD * radius);
    float innerRadius=userInnerRadius;
    float shift=set.getSelectionShift();
    final float highlightedRadius=radius + shift;
    highlightedCircleBox.set(mChart.getCircleBox());
    highlightedCircleBox.inset(-shift,-shift);
    mRenderPaint.setColor(set.getColor(xIndex));
    final float startAngleOuter=rotationAngle + (angle + sliceSpaceOuterAngle / 2.f) * phaseY;
    float sweepAngleOuter=(sliceAngle - sliceSpaceOuterAngle) * phaseY;
    if (sweepAngleOuter < 0.f) {
      sweepAngleOuter=0.f;
    }
    mPathBuffer.reset();
    if (sweepAngleOuter % 360f == 0.f) {
      mPathBuffer.addCircle(center.x,center.y,highlightedRadius,Path.Direction.CW);
    }
 else {
      mPathBuffer.moveTo(center.x + highlightedRadius * (float)Math.cos(startAngleOuter * Utils.FDEG2RAD),center.y + highlightedRadius * (float)Math.sin(startAngleOuter * Utils.FDEG2RAD));
      mPathBuffer.arcTo(highlightedCircleBox,startAngleOuter,sweepAngleOuter);
    }
    if (sliceSpace > 0.f) {
      innerRadius=Math.max(innerRadius,calculateMinimumRadiusForSpacedSlice(center,radius,sliceAngle * phaseY,center.x + radius * (float)Math.cos(startAngleOuter * Utils.FDEG2RAD),center.y + radius * (float)Math.sin(startAngleOuter * Utils.FDEG2RAD),startAngleOuter,sweepAngleOuter));
    }
    mInnerRectBuffer.set(center.x - innerRadius,center.y - innerRadius,center.x + innerRadius,center.y + innerRadius);
    if (innerRadius > 0.0) {
      final float sliceSpaceInnerAngle=visibleAngleCount == 1 ? 0.f : sliceSpace / (Utils.FDEG2RAD * innerRadius);
      final float startAngleInner=rotationAngle + (angle + sliceSpaceInnerAngle / 2.f) * phaseY;
      float sweepAngleInner=(sliceAngle - sliceSpaceInnerAngle) * phaseY;
      if (sweepAngleInner < 0.f) {
        sweepAngleInner=0.f;
      }
      final float endAngleInner=startAngleInner + sweepAngleInner;
      if (sweepAngleOuter % 360f == 0.f) {
        mPathBuffer.addCircle(center.x,center.y,innerRadius,Path.Direction.CCW);
      }
 else {
        mPathBuffer.lineTo(center.x + innerRadius * (float)Math.cos(endAngleInner * Utils.FDEG2RAD),center.y + innerRadius * (float)Math.sin(endAngleInner * Utils.FDEG2RAD));
        mPathBuffer.arcTo(mInnerRectBuffer,endAngleInner,-sweepAngleInner);
      }
    }
 else {
      if (sweepAngleOuter % 360f != 0.f) {
        mPathBuffer.lineTo(center.x,center.y);
      }
    }
    mPathBuffer.close();
    mBitmapCanvas.drawPath(mPathBuffer,mRenderPaint);
  }
}

Fixed version (ground truth):
@Override public void drawHighlighted(Canvas c,Highlight[] indices){
  float phaseX=mAnimator.getPhaseX();
  float phaseY=mAnimator.getPhaseY();
  float angle;
  float rotationAngle=mChart.getRotationAngle();
  float[] drawAngles=mChart.getDrawAngles();
  float[] absoluteAngles=mChart.getAbsoluteAngles();
  final PointF center=mChart.getCenterCircleBox();
  final float radius=mChart.getRadius();
  final boolean drawInnerArc=mChart.isDrawHoleEnabled() && !mChart.isDrawSlicesUnderHoleEnabled();
  final float userInnerRadius=drawInnerArc ? radius * (mChart.getHoleRadius() / 100.f) : 0.f;
  final RectF highlightedCircleBox=new RectF();
  for (int i=0; i < indices.length; i++) {
    int xIndex=indices[i].getXIndex();
    if (xIndex >= drawAngles.length)     continue;
    IPieDataSet set=mChart.getData().getDataSetByIndex(indices[i].getDataSetIndex());
    if (set == null || !set.isHighlightEnabled())     continue;
    final int entryCount=set.getEntryCount();
    int visibleAngleCount=0;
    for (int j=0; j < entryCount; j++) {
      if ((Math.abs(set.getEntryForIndex(j).getVal()) > 0.000001)) {
        visibleAngleCount++;
      }
    }
    if (xIndex == 0)     angle=0.f;
 else     angle=absoluteAngles[xIndex - 1] * phaseX;
    float sliceSpace=set.getSliceSpace();
    float sliceAngle=drawAngles[xIndex];
    float innerRadius=userInnerRadius;
    float shift=set.getSelectionShift();
    final float highlightedRadius=radius + shift;
    highlightedCircleBox.set(mChart.getCircleBox());
    highlightedCircleBox.inset(-shift,-shift);
    mRenderPaint.setColor(set.getColor(xIndex));
    final float sliceSpaceAngleOuter=visibleAngleCount == 1 ? 0.f : sliceSpace / (Utils.FDEG2RAD * radius);
    final float sliceSpaceAngleShifted=visibleAngleCount == 1 ? 0.f : sliceSpace / (Utils.FDEG2RAD * highlightedRadius);
    final float startAngleOuter=rotationAngle + (angle + sliceSpaceAngleOuter / 2.f) * phaseY;
    float sweepAngleOuter=(sliceAngle - sliceSpaceAngleOuter) * phaseY;
    if (sweepAngleOuter < 0.f) {
      sweepAngleOuter=0.f;
    }
    final float startAngleShifted=rotationAngle + (angle + sliceSpaceAngleShifted / 2.f) * phaseY;
    float sweepAngleShifted=(sliceAngle - sliceSpaceAngleShifted) * phaseY;
    if (sweepAngleShifted < 0.f) {
      sweepAngleShifted=0.f;
    }
    mPathBuffer.reset();
    if (sweepAngleOuter % 360f == 0.f) {
      mPathBuffer.addCircle(center.x,center.y,highlightedRadius,Path.Direction.CW);
    }
 else {
      mPathBuffer.moveTo(center.x + highlightedRadius * (float)Math.cos(startAngleShifted * Utils.FDEG2RAD),center.y + highlightedRadius * (float)Math.sin(startAngleShifted * Utils.FDEG2RAD));
      mPathBuffer.arcTo(highlightedCircleBox,startAngleShifted,sweepAngleShifted);
    }
    float sliceSpaceRadius=0.f;
    if (sliceSpace > 0.f) {
      sliceSpaceRadius=calculateMinimumRadiusForSpacedSlice(center,radius,sliceAngle * phaseY,center.x + radius * (float)Math.cos(startAngleOuter * Utils.FDEG2RAD),center.y + radius * (float)Math.sin(startAngleOuter * Utils.FDEG2RAD),startAngleOuter,sweepAngleOuter);
    }
    mInnerRectBuffer.set(center.x - innerRadius,center.y - innerRadius,center.x + innerRadius,center.y + innerRadius);
    if (drawInnerArc && (innerRadius > 0.f || sliceSpace > 0.f)) {
      if (sliceSpace > 0.f) {
        float minSpacedRadius=sliceSpaceRadius;
        if (minSpacedRadius < 0.f)         minSpacedRadius=-minSpacedRadius;
        innerRadius=Math.max(innerRadius,minSpacedRadius);
      }
      final float sliceSpaceAngleInner=visibleAngleCount == 1 || innerRadius == 0.f ? 0.f : sliceSpace / (Utils.FDEG2RAD * innerRadius);
      final float startAngleInner=rotationAngle + (angle + sliceSpaceAngleInner / 2.f) * phaseY;
      float sweepAngleInner=(sliceAngle - sliceSpaceAngleInner) * phaseY;
      if (sweepAngleInner < 0.f) {
        sweepAngleInner=0.f;
      }
      final float endAngleInner=startAngleInner + sweepAngleInner;
      if (sweepAngleOuter % 360f == 0.f) {
        mPathBuffer.addCircle(center.x,center.y,innerRadius,Path.Direction.CCW);
      }
 else {
        mPathBuffer.lineTo(center.x + innerRadius * (float)Math.cos(endAngleInner * Utils.FDEG2RAD),center.y + innerRadius * (float)Math.sin(endAngleInner * Utils.FDEG2RAD));
        mPathBuffer.arcTo(mInnerRectBuffer,endAngleInner,-sweepAngleInner);
      }
    }
 else {
      if (sweepAngleOuter % 360f != 0.f) {
        if (sliceSpace > 0.0) {
          final float angleMiddle=startAngleOuter + sweepAngleOuter / 2.f;
          final float arcEndPointX=center.x + sliceSpaceRadius * (float)Math.cos(angleMiddle * Utils.FDEG2RAD);
          final float arcEndPointY=center.y + sliceSpaceRadius * (float)Math.sin(angleMiddle * Utils.FDEG2RAD);
          mPathBuffer.lineTo(arcEndPointX,arcEndPointY);
        }
 else {
          mPathBuffer.lineTo(center.x,center.y);
        }
      }
    }
    mPathBuffer.close();
    mBitmapCanvas.drawPath(mPathBuffer,mRenderPaint);
  }
}