Program: 185026
Project: 185026
Buggy source:
public void populateOrigins(){
  clear();
  HashMap<String,Site> uris=new HashMap<String,Site>();
  Set origins=WebStorage.getInstance().getOrigins();
  if (origins != null) {
    Iterator<String> iter=origins.iterator();
    while (iter.hasNext()) {
      String origin=iter.next();
      Site site=new Site(origin);
      uris.put(Uri.parse(origin).getHost(),site);
    }
  }
  Cursor c=getContext().getContentResolver().query(Browser.BOOKMARKS_URI,new String[]{Browser.BookmarkColumns.URL,Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.FAVICON},"String_Node_Str",null,null);
  if ((c != null) && c.moveToFirst()) {
    int urlIndex=c.getColumnIndex(Browser.BookmarkColumns.URL);
    int titleIndex=c.getColumnIndex(Browser.BookmarkColumns.TITLE);
    int faviconIndex=c.getColumnIndex(Browser.BookmarkColumns.FAVICON);
    do {
      String url=c.getString(urlIndex);
      String host=Uri.parse(url).getHost();
      if (uris.containsKey(host)) {
        String title=c.getString(titleIndex);
        Site site=uris.get(host);
        site.setTitle(title);
        byte[] data=c.getBlob(faviconIndex);
        if (data != null) {
          Bitmap bmp=BitmapFactory.decodeByteArray(data,0,data.length);
          if (bmp != null) {
            site.setIcon(bmp);
          }
        }
      }
    }
 while (c.moveToNext());
  }
  Set keys=uris.keySet();
  Iterator iter=keys.iterator();
  while (iter.hasNext()) {
    String origin=(String)iter.next();
    Site site=uris.get(origin);
    add(site);
  }
  if (getCount() == 0) {
    finish();
  }
}

Fixed version (ground truth):
public void populateOrigins(){
  clear();
  Set origins=WebStorage.getInstance().getOrigins();
  Set sites=new HashSet<Site>();
  if (origins != null) {
    Iterator<String> iter=origins.iterator();
    while (iter.hasNext()) {
      String origin=iter.next();
      Site site=new Site(origin);
      sites.add(site);
    }
  }
  HashMap hosts=new HashMap<String,Set<Site>>();
  Iterator<Site> sitesIter=sites.iterator();
  while (sitesIter.hasNext()) {
    Site site=sitesIter.next();
    String host=Uri.parse(site.getOrigin()).getHost();
    Set hostSites=null;
    if (hosts.containsKey(host)) {
      hostSites=(Set)hosts.get(host);
    }
 else {
      hostSites=new HashSet<Site>();
      hosts.put(host,hostSites);
    }
    hostSites.add(site);
  }
  Cursor c=getContext().getContentResolver().query(Browser.BOOKMARKS_URI,new String[]{Browser.BookmarkColumns.URL,Browser.BookmarkColumns.TITLE,Browser.BookmarkColumns.FAVICON},"String_Node_Str",null,null);
  if ((c != null) && c.moveToFirst()) {
    int urlIndex=c.getColumnIndex(Browser.BookmarkColumns.URL);
    int titleIndex=c.getColumnIndex(Browser.BookmarkColumns.TITLE);
    int faviconIndex=c.getColumnIndex(Browser.BookmarkColumns.FAVICON);
    do {
      String url=c.getString(urlIndex);
      String host=Uri.parse(url).getHost();
      if (hosts.containsKey(host)) {
        String title=c.getString(titleIndex);
        Bitmap bmp=null;
        byte[] data=c.getBlob(faviconIndex);
        if (data != null) {
          bmp=BitmapFactory.decodeByteArray(data,0,data.length);
        }
        Set matchingSites=(Set)hosts.get(host);
        sitesIter=matchingSites.iterator();
        while (sitesIter.hasNext()) {
          Site site=sitesIter.next();
          site.setTitle(title);
          if (bmp != null) {
            site.setIcon(bmp);
          }
        }
      }
    }
 while (c.moveToNext());
  }
  sitesIter=sites.iterator();
  while (sitesIter.hasNext()) {
    Site site=sitesIter.next();
    add(site);
  }
  if (getCount() == 0) {
    finish();
  }
}