Program: 66680
Project: 66680
Buggy source:
public static ColumnsInfo createTable(ITableContent table,int width,int dpi){
  int tableWidth=getElementWidth(table,width,dpi);
  int columnCount=table.getColumnCount();
  if (columnCount == 0) {
    return null;
  }
  int[] columns=new int[columnCount];
  int unassignedCount=0;
  int totalAssigned=0;
  for (int i=0; i < columnCount; i++) {
    DimensionType value=table.getColumn(i).getWidth();
    if (value == null) {
      columns[i]=-1;
      unassignedCount++;
    }
 else {
      columns[i]=ExcelUtil.convertDimensionType(value,tableWidth,dpi);
      totalAssigned+=columns[i];
    }
  }
  int leftWidth=tableWidth - totalAssigned;
  if (leftWidth > 0 && unassignedCount == 0 && table.getWidth() != null) {
    int totalResized=0;
    for (int i=0; i < columnCount - 1; i++) {
      columns[i]=resize(columns[i],totalAssigned,leftWidth);
      totalResized+=columns[i];
    }
    columns[columnCount - 1]=tableWidth - totalResized;
  }
 else   if (leftWidth < 0 && unassignedCount > 0) {
    int totalResized=0;
    int lastAssignedIndex=0;
    for (int i=0; i < columnCount; i++) {
      if (columns[i] == -1) {
        columns[i]=0;
      }
 else {
        columns[i]=resize(columns[i],totalAssigned,leftWidth);
        lastAssignedIndex=i;
      }
      totalResized+=columns[i];
    }
    columns[lastAssignedIndex]+=tableWidth - totalResized;
  }
 else   if (leftWidth >= 0 && unassignedCount > 0) {
    int per=(int)leftWidth / unassignedCount;
    int index=0;
    for (int i=0; i < columns.length; i++) {
      if (columns[i] == -1) {
        columns[i]=per;
        index=i;
      }
    }
    columns[index]=leftWidth - per * (unassignedCount - 1);
  }
  return new ColumnsInfo(columns);
}

Fixed version (ground truth):
public static ColumnsInfo createTable(ITableContent table,int width,int dpi,boolean autoExtend){
  int tableWidth=getElementWidth(table,width,dpi);
  int columnCount=table.getColumnCount();
  if (columnCount == 0) {
    return null;
  }
  int[] columns=new int[columnCount];
  int unassignedCount=0;
  int totalAssigned=0;
  for (int i=0; i < columnCount; i++) {
    DimensionType value=table.getColumn(i).getWidth();
    if (value == null) {
      columns[i]=-1;
      unassignedCount++;
    }
 else {
      columns[i]=ExcelUtil.convertDimensionType(value,tableWidth,dpi);
      totalAssigned+=columns[i];
    }
  }
  int leftWidth=tableWidth - totalAssigned;
  if ((leftWidth > 0 || !autoExtend && leftWidth < 0) && unassignedCount == 0 && table.getWidth() != null) {
    int totalResized=0;
    for (int i=0; i < columnCount - 1; i++) {
      columns[i]=resize(columns[i],totalAssigned,leftWidth);
      totalResized+=columns[i];
    }
    columns[columnCount - 1]=tableWidth - totalResized;
  }
 else   if (leftWidth < 0 && unassignedCount > 0) {
    int totalResized=0;
    int lastAssignedIndex=0;
    for (int i=0; i < columnCount; i++) {
      if (columns[i] == -1) {
        columns[i]=0;
      }
 else       if (!autoExtend) {
        columns[i]=resize(columns[i],totalAssigned,leftWidth);
        lastAssignedIndex=i;
      }
      totalResized+=columns[i];
    }
    columns[lastAssignedIndex]+=tableWidth - totalResized;
  }
 else   if (leftWidth >= 0 && unassignedCount > 0) {
    int per=(int)leftWidth / unassignedCount;
    int index=0;
    for (int i=0; i < columns.length; i++) {
      if (columns[i] == -1) {
        columns[i]=per;
        index=i;
      }
    }
    columns[index]=leftWidth - per * (unassignedCount - 1);
  }
  return new ColumnsInfo(columns);
}