Program: 18244
Project: 18244
Buggy source:
@Override public void drawValues(Canvas c){
  if (passesCheck()) {
    List<IBarDataSet> dataSets=mChart.getBarData().getDataSets();
    final float valueOffsetPlus=Utils.convertDpToPixel(5f);
    float posOffset=0f;
    float negOffset=0f;
    final boolean drawValueAboveBar=mChart.isDrawValueAboveBarEnabled();
    for (int i=0; i < mChart.getBarData().getDataSetCount(); i++) {
      IBarDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      boolean isInverted=mChart.isInverted(dataSet.getAxisDependency());
      applyValueTextStyle(dataSet);
      final float halfTextHeight=Utils.calcTextHeight(mValuePaint,"String_Node_Str") / 2f;
      ValueFormatter formatter=dataSet.getValueFormatter();
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      float[] valuePoints=getTransformedValues(trans,dataSet,i);
      if (!dataSet.isStacked()) {
        for (int j=0; j < valuePoints.length * mAnimator.getPhaseX(); j+=2) {
          if (!mViewPortHandler.isInBoundsTop(valuePoints[j + 1]))           break;
          if (!mViewPortHandler.isInBoundsX(valuePoints[j]))           continue;
          if (!mViewPortHandler.isInBoundsBottom(valuePoints[j + 1]))           continue;
          BarEntry e=dataSet.getEntryForIndex(j / 2);
          float val=e.getVal();
          String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
          float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
          posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
          negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
          if (isInverted) {
            posOffset=-posOffset - valueTextWidth;
            negOffset=-negOffset - valueTextWidth;
          }
          drawValue(c,formattedValue,valuePoints[j] + (val >= 0 ? posOffset : negOffset),valuePoints[j + 1] + halfTextHeight);
        }
      }
 else {
        for (int j=0; j < (valuePoints.length - 1) * mAnimator.getPhaseX(); j+=2) {
          BarEntry e=dataSet.getEntryForIndex(j / 2);
          float[] vals=e.getVals();
          if (vals == null) {
            if (!mViewPortHandler.isInBoundsTop(valuePoints[j + 1]))             break;
            if (!mViewPortHandler.isInBoundsX(valuePoints[j]))             continue;
            if (!mViewPortHandler.isInBoundsBottom(valuePoints[j + 1]))             continue;
            float val=e.getVal();
            String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
            float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
            posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
            negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
            if (isInverted) {
              posOffset=-posOffset - valueTextWidth;
              negOffset=-negOffset - valueTextWidth;
            }
            drawValue(c,formattedValue,valuePoints[j] + (e.getVal() >= 0 ? posOffset : negOffset),valuePoints[j + 1] + halfTextHeight);
          }
 else {
            float[] transformed=new float[vals.length * 2];
            float posY=0f;
            float negY=-e.getNegativeSum();
            for (int k=0, idx=0; k < transformed.length; k+=2, idx++) {
              float value=vals[idx];
              float y;
              if (value >= 0f) {
                posY+=value;
                y=posY;
              }
 else {
                y=negY;
                negY-=value;
              }
              transformed[k]=y * mAnimator.getPhaseY();
            }
            trans.pointValuesToPixel(transformed);
            for (int k=0; k < transformed.length; k+=2) {
              float val=vals[k / 2];
              String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
              float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
              posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
              negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
              if (isInverted) {
                posOffset=-posOffset - valueTextWidth;
                negOffset=-negOffset - valueTextWidth;
              }
              float x=transformed[k] + (val >= 0 ? posOffset : negOffset);
              float y=valuePoints[j + 1];
              if (!mViewPortHandler.isInBoundsTop(y))               break;
              if (!mViewPortHandler.isInBoundsX(x))               continue;
              if (!mViewPortHandler.isInBoundsBottom(y))               continue;
              drawValue(c,formattedValue,x,y + halfTextHeight);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  if (passesCheck()) {
    List<IBarDataSet> dataSets=mChart.getBarData().getDataSets();
    final float valueOffsetPlus=Utils.convertDpToPixel(5f);
    float posOffset=0f;
    float negOffset=0f;
    final boolean drawValueAboveBar=mChart.isDrawValueAboveBarEnabled();
    for (int i=0; i < mChart.getBarData().getDataSetCount(); i++) {
      IBarDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      boolean isInverted=mChart.isInverted(dataSet.getAxisDependency());
      applyValueTextStyle(dataSet);
      final float halfTextHeight=Utils.calcTextHeight(mValuePaint,"String_Node_Str") / 2f;
      ValueFormatter formatter=dataSet.getValueFormatter();
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      float[] valuePoints=getTransformedValues(trans,dataSet,i);
      if (!dataSet.isStacked()) {
        for (int j=0; j < valuePoints.length * mAnimator.getPhaseX(); j+=2) {
          if (!mViewPortHandler.isInBoundsTop(valuePoints[j + 1]))           break;
          if (!mViewPortHandler.isInBoundsX(valuePoints[j]))           continue;
          if (!mViewPortHandler.isInBoundsBottom(valuePoints[j + 1]))           continue;
          BarEntry e=dataSet.getEntryForIndex(j / 2);
          float val=e.getVal();
          String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
          float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
          posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
          negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
          if (isInverted) {
            posOffset=-posOffset - valueTextWidth;
            negOffset=-negOffset - valueTextWidth;
          }
          drawValue(c,formattedValue,valuePoints[j] + (val >= 0 ? posOffset : negOffset),valuePoints[j + 1] + halfTextHeight,dataSet.getValueTextColor(j / 2));
        }
      }
 else {
        for (int j=0; j < (valuePoints.length - 1) * mAnimator.getPhaseX(); j+=2) {
          BarEntry e=dataSet.getEntryForIndex(j / 2);
          float[] vals=e.getVals();
          if (vals == null) {
            if (!mViewPortHandler.isInBoundsTop(valuePoints[j + 1]))             break;
            if (!mViewPortHandler.isInBoundsX(valuePoints[j]))             continue;
            if (!mViewPortHandler.isInBoundsBottom(valuePoints[j + 1]))             continue;
            float val=e.getVal();
            String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
            float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
            posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
            negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
            if (isInverted) {
              posOffset=-posOffset - valueTextWidth;
              negOffset=-negOffset - valueTextWidth;
            }
            drawValue(c,formattedValue,valuePoints[j] + (e.getVal() >= 0 ? posOffset : negOffset),valuePoints[j + 1] + halfTextHeight,dataSet.getValueTextColor(j / 2));
          }
 else {
            float[] transformed=new float[vals.length * 2];
            float posY=0f;
            float negY=-e.getNegativeSum();
            for (int k=0, idx=0; k < transformed.length; k+=2, idx++) {
              float value=vals[idx];
              float y;
              if (value >= 0f) {
                posY+=value;
                y=posY;
              }
 else {
                y=negY;
                negY-=value;
              }
              transformed[k]=y * mAnimator.getPhaseY();
            }
            trans.pointValuesToPixel(transformed);
            for (int k=0; k < transformed.length; k+=2) {
              float val=vals[k / 2];
              String formattedValue=formatter.getFormattedValue(val,e,i,mViewPortHandler);
              float valueTextWidth=Utils.calcTextWidth(mValuePaint,formattedValue);
              posOffset=(drawValueAboveBar ? valueOffsetPlus : -(valueTextWidth + valueOffsetPlus));
              negOffset=(drawValueAboveBar ? -(valueTextWidth + valueOffsetPlus) : valueOffsetPlus);
              if (isInverted) {
                posOffset=-posOffset - valueTextWidth;
                negOffset=-negOffset - valueTextWidth;
              }
              float x=transformed[k] + (val >= 0 ? posOffset : negOffset);
              float y=valuePoints[j + 1];
              if (!mViewPortHandler.isInBoundsTop(y))               break;
              if (!mViewPortHandler.isInBoundsX(x))               continue;
              if (!mViewPortHandler.isInBoundsBottom(y))               continue;
              drawValue(c,formattedValue,x,y + halfTextHeight,dataSet.getValueTextColor(j / 2));
            }
          }
        }
      }
    }
  }
}