Program: 74511
Project: 74511
Buggy source:
protected void formalize(DimensionType[] columns,int tableWidth){
  ArrayList percentageList=new ArrayList();
  ArrayList unsetList=new ArrayList();
  double total=0.0f;
  int fixedLength=0;
  for (int i=0; i < columns.length; i++) {
    if (columns[i] == null) {
      unsetList.add(new Integer(i));
    }
 else     if (EngineIRConstants.UNITS_PERCENTAGE.equals(columns[i].getUnits())) {
      percentageList.add(new Integer(i));
      total+=columns[i].getMeasure();
    }
 else {
      int len=PDFTableLM.this.getDimensionValue(columns[i],tableWidth);
      fixedLength+=len;
    }
  }
  if (fixedLength >= tableWidth) {
    for (int i=0; i < unsetList.size(); i++) {
      Integer index=(Integer)unsetList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
    for (int i=0; i < percentageList.size(); i++) {
      Integer index=(Integer)percentageList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
  }
 else {
    float leftPercentage=(((float)(tableWidth - fixedLength)) / tableWidth) * 100.0f;
    if (unsetList.isEmpty()) {
      double ratio=leftPercentage / total;
      for (int i=0; i < percentageList.size(); i++) {
        Integer index=(Integer)percentageList.get(i);
        columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
      }
    }
 else {
      if (total < leftPercentage) {
        double delta=leftPercentage - total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(delta / (double)unsetList.size(),EngineIRConstants.UNITS_PERCENTAGE);
        }
      }
 else {
        double ratio=leftPercentage / total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
        }
        for (int i=0; i < percentageList.size(); i++) {
          Integer index=(Integer)percentageList.get(i);
          columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
        }
      }
    }
  }
}

Fixed version (ground truth):
protected void formalize(DimensionType[] columns,int tableWidth){
  ArrayList percentageList=new ArrayList();
  ArrayList unsetList=new ArrayList();
  double total=0.0f;
  int fixedLength=0;
  for (int i=0; i < columns.length; i++) {
    if (columns[i] == null) {
      unsetList.add(new Integer(i));
    }
 else     if (EngineIRConstants.UNITS_PERCENTAGE.equals(columns[i].getUnits())) {
      percentageList.add(new Integer(i));
      total+=columns[i].getMeasure();
    }
 else     if (EngineIRConstants.UNITS_EM.equals(columns[i].getUnits()) || EngineIRConstants.UNITS_EX.equals(columns[i].getUnits())) {
      int len=PDFTableLM.this.getDimensionValue(columns[i],PropertyUtil.getDimensionValue(table.getComputedStyle().getProperty(StyleConstants.STYLE_FONT_SIZE)));
      fixedLength+=len;
    }
 else {
      int len=PDFTableLM.this.getDimensionValue(columns[i],tableWidth);
      fixedLength+=len;
    }
  }
  if (fixedLength >= tableWidth) {
    for (int i=0; i < unsetList.size(); i++) {
      Integer index=(Integer)unsetList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
    for (int i=0; i < percentageList.size(); i++) {
      Integer index=(Integer)percentageList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
  }
 else {
    float leftPercentage=(((float)(tableWidth - fixedLength)) / tableWidth) * 100.0f;
    if (unsetList.isEmpty()) {
      double ratio=leftPercentage / total;
      for (int i=0; i < percentageList.size(); i++) {
        Integer index=(Integer)percentageList.get(i);
        columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
      }
    }
 else {
      if (total < leftPercentage) {
        double delta=leftPercentage - total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(delta / (double)unsetList.size(),EngineIRConstants.UNITS_PERCENTAGE);
        }
      }
 else {
        double ratio=leftPercentage / total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
        }
        for (int i=0; i < percentageList.size(); i++) {
          Integer index=(Integer)percentageList.get(i);
          columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
        }
      }
    }
  }
}