Program: 21371
Project: 21371
Buggy source:
/** 
 * @return gibt das globale speedmeter zurück
 */
public int getSpeedMeter(){
  Iterator<DownloadLink> iter=getDownloadLinks().iterator();
  int ret=0;
  int c=0;
  while (iter.hasNext()) {
    DownloadLink element=(DownloadLink)iter.next();
    if (element.isInProgress()) {
      c++;
      ret+=element.getDownloadSpeed();
    }
  }
  if (c > 0) {
    int maxspeed=JDUtilities.getConfiguration().getIntegerProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,0) * 1024;
    if (maxspeed != 0) {
      int maxsp=maxspeed / c;
      int overhead=0;
      iter=getDownloadLinks().iterator();
      while (iter.hasNext()) {
        DownloadLink element=(DownloadLink)iter.next();
        if (element.isInProgress()) {
          int elspeed=element.getDownloadSpeed();
          int sp=maxsp + overhead;
          if (elspeed < sp)           overhead=sp - elspeed;
 else           overhead=0;
          element.setMaximalspeed(sp);
        }
      }
      if (overhead > 0) {
        iter=getDownloadLinks().iterator();
        int sp=maxsp + overhead;
        while (iter.hasNext()) {
          DownloadLink element=(DownloadLink)iter.next();
          if (element.isInProgress()) {
            if (element.getMaximalspeed() < sp) {
              element.setMaximalspeed(sp);
              break;
            }
          }
        }
      }
    }
 else {
      iter=getDownloadLinks().iterator();
      int sp=ret + 204800;
      while (iter.hasNext()) {
        DownloadLink element=(DownloadLink)iter.next();
        if (element.isInProgress()) {
          element.setMaximalspeed(sp);
        }
      }
    }
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * @return gibt das globale speedmeter zurück
 */
public int getSpeedMeter(){
  Iterator<DownloadLink> iter=getDownloadLinks().iterator();
  int ret=0;
  int c=0;
  int maxspeed=JDUtilities.getConfiguration().getIntegerProperty(Configuration.PARAM_DOWNLOAD_MAX_SPEED,0) * 1024;
  boolean isLimited=(maxspeed != 0);
  while (iter.hasNext()) {
    DownloadLink element=(DownloadLink)iter.next();
    if (element.isInProgress()) {
      c++;
      ret+=element.getDownloadSpeed();
      element.isLimited=isLimited;
    }
  }
  if (c > 0) {
    if (maxspeed != 0) {
      int maxsp=maxspeed / c;
      int overhead=0;
      iter=getDownloadLinks().iterator();
      while (iter.hasNext()) {
        DownloadLink element=(DownloadLink)iter.next();
        if (element.isInProgress()) {
          int elspeed=element.getDownloadSpeed();
          int sp=maxsp + overhead;
          if (elspeed < sp)           overhead=sp - elspeed;
 else           overhead=0;
          element.setMaximalspeed(sp);
        }
      }
      if (overhead > 0) {
        iter=getDownloadLinks().iterator();
        int sp=maxsp + overhead;
        while (iter.hasNext()) {
          DownloadLink element=(DownloadLink)iter.next();
          if (element.isInProgress()) {
            if (element.getMaximalspeed() < sp) {
              element.setMaximalspeed(sp);
              break;
            }
          }
        }
      }
    }
 else {
      iter=getDownloadLinks().iterator();
      int sp=ret + 204800;
      while (iter.hasNext()) {
        DownloadLink element=(DownloadLink)iter.next();
        if (element.isInProgress()) {
          element.setMaximalspeed(sp);
        }
      }
    }
  }
  return ret;
}