Program: 26433
Project: 26433
Buggy source:
@Override public void drawValues(Canvas c){
  if (passesCheck()) {
    List<BarDataSet> dataSets=mChart.getBarData().getDataSets();
    final float valueOffsetPlus=Utils.convertDpToPixel(4.5f);
    float posOffset=0f;
    float negOffset=0f;
    boolean drawValueAboveBar=mChart.isDrawValueAboveBarEnabled();
    for (int i=0; i < mChart.getBarData().getDataSetCount(); i++) {
      BarDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled())       continue;
      applyValueTextStyle(dataSet);
      boolean isInverted=mChart.isInverted(dataSet.getAxisDependency());
      float valueTextHeight=Utils.calcTextHeight(mValuePaint,"String_Node_Str");
      posOffset=(drawValueAboveBar ? -valueOffsetPlus : valueTextHeight + valueOffsetPlus);
      negOffset=(drawValueAboveBar ? valueTextHeight + valueOffsetPlus : -valueOffsetPlus);
      if (isInverted) {
        posOffset=-posOffset - valueTextHeight;
        negOffset=-negOffset - valueTextHeight;
      }
      ValueFormatter formatter=dataSet.getValueFormatter();
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      List<BarEntry> entries=dataSet.getYVals();
      float[] valuePoints=getTransformedValues(trans,entries,i);
      if (!dataSet.isStacked()) {
        for (int j=0; j < valuePoints.length * mAnimator.getPhaseX(); j+=2) {
          if (!mViewPortHandler.isInBoundsRight(valuePoints[j]))           break;
          if (!mViewPortHandler.isInBoundsY(valuePoints[j + 1]) || !mViewPortHandler.isInBoundsLeft(valuePoints[j]))           continue;
          float val=entries.get(j / 2).getVal();
          drawValue(c,formatter.getFormattedValue(val),valuePoints[j],valuePoints[j + 1] + (val >= 0 ? posOffset : negOffset));
        }
      }
 else {
        for (int j=0; j < (valuePoints.length - 1) * mAnimator.getPhaseX(); j+=2) {
          BarEntry e=entries.get(j / 2);
          float[] vals=e.getVals();
          if (vals == null) {
            if (!mViewPortHandler.isInBoundsRight(valuePoints[j]))             break;
            if (!mViewPortHandler.isInBoundsY(valuePoints[j + 1]) || !mViewPortHandler.isInBoundsLeft(valuePoints[j]))             continue;
            drawValue(c,formatter.getFormattedValue(e.getVal()),valuePoints[j],valuePoints[j + 1] + (e.getVal() >= 0 ? posOffset : negOffset));
          }
 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 + 1]=y * mAnimator.getPhaseY();
            }
            trans.pointValuesToPixel(transformed);
            for (int k=0; k < transformed.length; k+=2) {
              float x=valuePoints[j];
              float y=transformed[k + 1] + (vals[k / 2] >= 0 ? posOffset : negOffset);
              if (!mViewPortHandler.isInBoundsRight(x))               break;
              if (!mViewPortHandler.isInBoundsY(y) || !mViewPortHandler.isInBoundsLeft(x))               continue;
              drawValue(c,formatter.getFormattedValue(vals[k / 2]),x,y);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void drawValues(Canvas c){
  if (passesCheck()) {
    List<BarDataSet> dataSets=mChart.getBarData().getDataSets();
    final float valueOffsetPlus=Utils.convertDpToPixel(4.5f);
    float posOffset=0f;
    float negOffset=0f;
    boolean drawValueAboveBar=mChart.isDrawValueAboveBarEnabled();
    for (int i=0; i < mChart.getBarData().getDataSetCount(); i++) {
      BarDataSet dataSet=dataSets.get(i);
      if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)       continue;
      applyValueTextStyle(dataSet);
      boolean isInverted=mChart.isInverted(dataSet.getAxisDependency());
      float valueTextHeight=Utils.calcTextHeight(mValuePaint,"String_Node_Str");
      posOffset=(drawValueAboveBar ? -valueOffsetPlus : valueTextHeight + valueOffsetPlus);
      negOffset=(drawValueAboveBar ? valueTextHeight + valueOffsetPlus : -valueOffsetPlus);
      if (isInverted) {
        posOffset=-posOffset - valueTextHeight;
        negOffset=-negOffset - valueTextHeight;
      }
      ValueFormatter formatter=dataSet.getValueFormatter();
      Transformer trans=mChart.getTransformer(dataSet.getAxisDependency());
      List<BarEntry> entries=dataSet.getYVals();
      float[] valuePoints=getTransformedValues(trans,entries,i);
      if (!dataSet.isStacked()) {
        for (int j=0; j < valuePoints.length * mAnimator.getPhaseX(); j+=2) {
          if (!mViewPortHandler.isInBoundsRight(valuePoints[j]))           break;
          if (!mViewPortHandler.isInBoundsY(valuePoints[j + 1]) || !mViewPortHandler.isInBoundsLeft(valuePoints[j]))           continue;
          float val=entries.get(j / 2).getVal();
          drawValue(c,formatter.getFormattedValue(val),valuePoints[j],valuePoints[j + 1] + (val >= 0 ? posOffset : negOffset));
        }
      }
 else {
        for (int j=0; j < (valuePoints.length - 1) * mAnimator.getPhaseX(); j+=2) {
          BarEntry e=entries.get(j / 2);
          float[] vals=e.getVals();
          if (vals == null) {
            if (!mViewPortHandler.isInBoundsRight(valuePoints[j]))             break;
            if (!mViewPortHandler.isInBoundsY(valuePoints[j + 1]) || !mViewPortHandler.isInBoundsLeft(valuePoints[j]))             continue;
            drawValue(c,formatter.getFormattedValue(e.getVal()),valuePoints[j],valuePoints[j + 1] + (e.getVal() >= 0 ? posOffset : negOffset));
          }
 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 + 1]=y * mAnimator.getPhaseY();
            }
            trans.pointValuesToPixel(transformed);
            for (int k=0; k < transformed.length; k+=2) {
              float x=valuePoints[j];
              float y=transformed[k + 1] + (vals[k / 2] >= 0 ? posOffset : negOffset);
              if (!mViewPortHandler.isInBoundsRight(x))               break;
              if (!mViewPortHandler.isInBoundsY(y) || !mViewPortHandler.isInBoundsLeft(x))               continue;
              drawValue(c,formatter.getFormattedValue(vals[k / 2]),x,y);
            }
          }
        }
      }
    }
  }
}