Program: 26261
Project: 26261
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 MPPointF 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=mDrawHighlightedRectF;
  highlightedCircleBox.set(0,0,0,0);
  for (int i=0; i < indices.length; i++) {
    int index=(int)indices[i].getX();
    if (index >= 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).getY()) > Utils.FLOAT_EPSILON)) {
        visibleAngleCount++;
      }
    }
    if (index == 0)     angle=0.f;
 else     angle=absoluteAngles[index - 1] * phaseX;
    final float sliceSpace=visibleAngleCount <= 1 ? 0.f : set.getSliceSpace();
    float sliceAngle=drawAngles[index];
    float innerRadius=userInnerRadius;
    float shift=set.getSelectionShift();
    final float highlightedRadius=radius + shift;
    highlightedCircleBox.set(mChart.getCircleBox());
    highlightedCircleBox.inset(-shift,-shift);
    final boolean accountForSliceSpacing=sliceSpace > 0.f && sliceAngle <= 180.f;
    mRenderPaint.setColor(set.getColor(index));
    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 (accountForSliceSpacing) {
      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 || accountForSliceSpacing)) {
      if (accountForSliceSpacing) {
        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 (accountForSliceSpacing) {
          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);
  }
  MPPointF.recycleInstance(center);
}

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 MPPointF 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=mDrawHighlightedRectF;
  highlightedCircleBox.set(0,0,0,0);
  for (int i=0; i < indices.length; i++) {
    int index=(int)indices[i].getX();
    if (index >= 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).getY()) > Utils.FLOAT_EPSILON)) {
        visibleAngleCount++;
      }
    }
    if (index == 0)     angle=0.f;
 else     angle=absoluteAngles[index - 1] * phaseX;
    final float sliceSpace=visibleAngleCount <= 1 ? 0.f : set.getSliceSpace();
    float sliceAngle=drawAngles[index];
    float innerRadius=userInnerRadius;
    float shift=set.getSelectionShift();
    final float highlightedRadius=radius + shift;
    highlightedCircleBox.set(mChart.getCircleBox());
    highlightedCircleBox.inset(-shift,-shift);
    final boolean accountForSliceSpacing=sliceSpace > 0.f && sliceAngle <= 180.f;
    mRenderPaint.setColor(set.getColor(index));
    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 >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
      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 (accountForSliceSpacing) {
      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 || accountForSliceSpacing)) {
      if (accountForSliceSpacing) {
        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 >= 360.f && sweepAngleOuter % 360f <= Utils.FLOAT_EPSILON) {
        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 > Utils.FLOAT_EPSILON) {
        if (accountForSliceSpacing) {
          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);
  }
  MPPointF.recycleInstance(center);
}