Program: 170792
Project: 170792
Buggy source:
@Override public void selected(MenuItem _menu,Object _target){
  TableRow[] rows=(TableRow[])_target;
  String cb_all_data="String_Node_Str";
  for (  TableRow row : rows) {
    Torrent torrent;
    String name;
    Object ds=row.getDataSource();
    Download download=null;
    ShareResource share=null;
    if (ds instanceof ShareResourceFile) {
      try {
        torrent=((ShareResourceFile)ds).getItem().getTorrent();
      }
 catch (      ShareException e) {
        continue;
      }
      name=((ShareResourceFile)ds).getName();
      share=(ShareResource)ds;
    }
 else     if (ds instanceof ShareResourceDir) {
      try {
        torrent=((ShareResourceDir)ds).getItem().getTorrent();
      }
 catch (      ShareException e) {
        continue;
      }
      name=((ShareResourceDir)ds).getName();
      share=(ShareResource)ds;
    }
 else     if (ds instanceof Download) {
      download=(Download)ds;
      torrent=download.getTorrent();
      name=download.getName();
    }
 else {
      continue;
    }
    Set<String> networks=new HashSet<>();
    if (share != null) {
      Map<String,String> properties=share.getProperties();
      String nets=properties.get(ShareManager.PR_NETWORKS);
      if (nets != null) {
        String[] bits=nets.split("String_Node_Str");
        for (        String bit : bits) {
          bit=AENetworkClassifier.internalise(bit.trim());
          if (bit != null) {
            networks.add(bit);
          }
        }
      }
    }
    if (download != null) {
      TorrentAttribute ta=plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_NETWORKS);
      String[] nets=download.getListAttribute(ta);
      networks.addAll(Arrays.asList(nets));
    }
    String cb_data=download == null ? UrlUtils.getMagnetURI(name,torrent) : UrlUtils.getMagnetURI(download);
    if (download != null) {
      List<Tag> tags=TagManagerFactory.getTagManager().getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL,PluginCoreUtils.unwrap(download));
      for (      Tag tag : tags) {
        if (tag.isPublic()) {
          cb_data+="String_Node_Str" + UrlUtils.encode(tag.getTagName(true));
        }
      }
    }
    String sources=sources_param.getValue();
    boolean add_sources=sources.equals("String_Node_Str") || (sources.equals("String_Node_Str") && share != null);
    if (add_sources) {
      if (networks.isEmpty()) {
        for (        String net : AENetworkClassifier.AT_NETWORKS) {
          if (isNetworkEnabled(net)) {
            networks.add(net);
          }
        }
      }
      if (networks.contains(AENetworkClassifier.AT_PUBLIC) && !cb_data.contains("String_Node_Str")) {
        InetAddress ip=NetworkAdmin.getSingleton().getDefaultPublicAddress();
        InetAddress ip_v6=NetworkAdmin.getSingleton().getDefaultPublicAddressV6();
        int port=TCPNetworkManager.getSingleton().getTCPListeningPortNumber();
        if (ip != null && port > 0) {
          cb_data+="String_Node_Str" + UrlUtils.encode(ip.getHostAddress() + "String_Node_Str" + port);
        }
        if (ip_v6 != null && port > 0) {
          cb_data+="String_Node_Str" + UrlUtils.encode(ip_v6.getHostAddress() + "String_Node_Str" + port);
        }
      }
    }
    cb_all_data+=(cb_all_data.length() == 0 ? "String_Node_Str" : "String_Node_Str") + cb_data;
  }
  try {
    plugin_interface.getUIManager().copyToClipBoard(cb_all_data);
  }
 catch (  Throwable e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void selected(MenuItem _menu,Object _target){
  TableRow[] rows=(TableRow[])_target;
  String cb_all_data="String_Node_Str";
  for (  TableRow row : rows) {
    Torrent torrent;
    String name;
    Object ds=row.getDataSource();
    Download download=null;
    ShareResource share=null;
    if (ds instanceof ShareResourceFile) {
      try {
        torrent=((ShareResourceFile)ds).getItem().getTorrent();
      }
 catch (      ShareException e) {
        continue;
      }
      name=((ShareResourceFile)ds).getName();
      share=(ShareResource)ds;
    }
 else     if (ds instanceof ShareResourceDir) {
      try {
        torrent=((ShareResourceDir)ds).getItem().getTorrent();
      }
 catch (      ShareException e) {
        continue;
      }
      name=((ShareResourceDir)ds).getName();
      share=(ShareResource)ds;
    }
 else     if (ds instanceof Download) {
      download=(Download)ds;
      torrent=download.getTorrent();
      name=download.getName();
    }
 else {
      continue;
    }
    boolean is_share=false;
    Set<String> networks=new HashSet<>();
    if (share != null) {
      is_share=true;
      Map<String,String> properties=share.getProperties();
      if (properties != null) {
        String nets=properties.get(ShareManager.PR_NETWORKS);
        if (nets != null) {
          String[] bits=nets.split("String_Node_Str");
          for (          String bit : bits) {
            bit=AENetworkClassifier.internalise(bit.trim());
            if (bit != null) {
              networks.add(bit);
            }
          }
        }
      }
    }
    if (download != null) {
      TorrentAttribute ta=plugin_interface.getTorrentManager().getAttribute(TorrentAttribute.TA_NETWORKS);
      String[] nets=download.getListAttribute(ta);
      networks.addAll(Arrays.asList(nets));
      try {
        byte[] hash=download.getTorrentHash();
        if (plugin_interface.getShareManager().lookupShare(hash) != null) {
          is_share=true;
        }
      }
 catch (      Throwable e) {
      }
    }
    String cb_data=download == null ? UrlUtils.getMagnetURI(name,torrent) : UrlUtils.getMagnetURI(download);
    if (download != null) {
      List<Tag> tags=TagManagerFactory.getTagManager().getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL,PluginCoreUtils.unwrap(download));
      for (      Tag tag : tags) {
        if (tag.isPublic()) {
          cb_data+="String_Node_Str" + UrlUtils.encode(tag.getTagName(true));
        }
      }
    }
    String sources=sources_param.getValue();
    boolean add_sources=sources.equals("String_Node_Str") || (sources.equals("String_Node_Str") && is_share);
    if (add_sources) {
      if (networks.isEmpty()) {
        for (        String net : AENetworkClassifier.AT_NETWORKS) {
          if (isNetworkEnabled(net)) {
            networks.add(net);
          }
        }
      }
      if (networks.contains(AENetworkClassifier.AT_PUBLIC) && !cb_data.contains("String_Node_Str")) {
        InetAddress ip=NetworkAdmin.getSingleton().getDefaultPublicAddress();
        InetAddress ip_v6=NetworkAdmin.getSingleton().getDefaultPublicAddressV6();
        int port=TCPNetworkManager.getSingleton().getTCPListeningPortNumber();
        if (ip != null && port > 0) {
          cb_data+="String_Node_Str" + UrlUtils.encode(ip.getHostAddress() + "String_Node_Str" + port);
        }
        if (ip_v6 != null && port > 0) {
          cb_data+="String_Node_Str" + UrlUtils.encode(ip_v6.getHostAddress() + "String_Node_Str" + port);
        }
      }
    }
    cb_all_data+=(cb_all_data.length() == 0 ? "String_Node_Str" : "String_Node_Str") + cb_data;
  }
  try {
    plugin_interface.getUIManager().copyToClipBoard(cb_all_data);
  }
 catch (  Throwable e) {
    e.printStackTrace();
  }
}