Program: 20862
Project: 20862
Buggy source:
/** 
 * Liefert den nächsten DownloadLink
 * @return Der nächste DownloadLink oder null
 */
public DownloadLink getNextDownloadLink(){
synchronized (DownloadLOCK) {
    if (this.reachedStopMark())     return null;
    DownloadLink nextDownloadLink=null;
    DownloadLink returnDownloadLink=null;
    try {
      for (      final FilePackage filePackage : dlc.getPackages()) {
        for (final Iterator<DownloadLink> it2=filePackage.getDownloadLinkList().iterator(); it2.hasNext(); ) {
          nextDownloadLink=it2.next();
          if (nextDownloadLink.isEnabled() && !nextDownloadLink.getLinkStatus().hasStatus(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE)) {
            if (nextDownloadLink.getPlugin().isPremiumDownload() || (getRemainingIPBlockWaittime(nextDownloadLink.getHost()) <= 0 && getRemainingTempUnavailWaittime(nextDownloadLink.getHost()) <= 0)) {
              if (!isDownloadLinkActive(nextDownloadLink)) {
                if (!nextDownloadLink.getLinkStatus().isPluginActive()) {
                  if (nextDownloadLink.getLinkStatus().isStatus(LinkStatus.TODO)) {
                    int maxPerHost=getSimultanDownloadNumPerHost();
                    if (activeDownloadsbyHosts(nextDownloadLink.getPlugin()) < (nextDownloadLink.getPlugin()).getMaxSimultanDownloadNum() && activeDownloadsbyHosts(nextDownloadLink.getPlugin()) < maxPerHost && nextDownloadLink.getPlugin().getWrapper().isEnabled()) {
                      if (returnDownloadLink == null) {
                        returnDownloadLink=nextDownloadLink;
                      }
 else {
                        if (nextDownloadLink.getPriority() > returnDownloadLink.getPriority())                         returnDownloadLink=nextDownloadLink;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
 catch (    Exception e) {
    }
    return returnDownloadLink;
  }
}

Fixed version (ground truth):
/** 
 * Liefert den nächsten DownloadLink
 * @return Der nächste DownloadLink oder null
 */
public DownloadLink getNextDownloadLink(){
synchronized (DownloadLOCK) {
    if (this.reachedStopMark())     return null;
    DownloadLink nextDownloadLink=null;
    DownloadLink returnDownloadLink=null;
    try {
      for (      final FilePackage filePackage : dlc.getPackages()) {
        for (final Iterator<DownloadLink> it2=filePackage.getDownloadLinkList().iterator(); it2.hasNext(); ) {
          nextDownloadLink=it2.next();
          if (nextDownloadLink.getPlugin() == null)           continue;
          if (nextDownloadLink.isEnabled() && !nextDownloadLink.getLinkStatus().hasStatus(LinkStatus.ERROR_TEMPORARILY_UNAVAILABLE)) {
            if (nextDownloadLink.getPlugin().isPremiumDownload() || (getRemainingIPBlockWaittime(nextDownloadLink.getHost()) <= 0 && getRemainingTempUnavailWaittime(nextDownloadLink.getHost()) <= 0)) {
              if (!isDownloadLinkActive(nextDownloadLink)) {
                if (!nextDownloadLink.getLinkStatus().isPluginActive()) {
                  if (nextDownloadLink.getLinkStatus().isStatus(LinkStatus.TODO)) {
                    int maxPerHost=getSimultanDownloadNumPerHost();
                    if (activeDownloadsbyHosts(nextDownloadLink.getPlugin()) < (nextDownloadLink.getPlugin()).getMaxSimultanDownloadNum() && activeDownloadsbyHosts(nextDownloadLink.getPlugin()) < maxPerHost && nextDownloadLink.getPlugin().getWrapper().isEnabled()) {
                      if (returnDownloadLink == null) {
                        returnDownloadLink=nextDownloadLink;
                      }
 else {
                        if (nextDownloadLink.getPriority() > returnDownloadLink.getPriority())                         returnDownloadLink=nextDownloadLink;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
 catch (    Exception e) {
    }
    return returnDownloadLink;
  }
}