Program: 101927
Project: 101927
Buggy source:
protected void downloadProfilePictures_async(){
  new Thread(new Runnable(){
    @Override public void run(){
      for (int i=0; i < friends.size(); i++) {
        int bestIndex=getBestFriend(i);
        final Friend f=friends.get(bestIndex);
        if (f.hasDownloadedProfilePicture())         continue;
        File file=new File(getCacheDir(),f.getUID());
        Bitmap picture=Tools.getBitmapFromFile(file);
        if (picture == null) {
          picture=Tools.downloadBitmap(f.getProfilePictureURL());
        }
        if (picture != null) {
          f.setProfilePic(picture);
          Tools.storePictureToFile(file,picture);
        }
        updateProfilePictureAtIndex(f,bestIndex);
        if (bestIndex != i)         i--;
      }
    }
    private void updateProfilePictureAtIndex(    final Friend f,    final int index){
      runOnUiThread(new Runnable(){
        @Override public void run(){
          View v=friendListView.getChildAt(index - friendListView.getFirstVisiblePosition());
          if (v != null) {
            ImageView iv=(ImageView)v.findViewById(R.id.profile_picture);
            if (f.hasDownloadedProfilePicture()) {
              iv.setImageBitmap(f.getProfilePicture());
            }
          }
        }
      }
);
    }
    private int getBestFriend(    int index){
      int viewingIndex=friendListView.getFirstVisiblePosition();
      int lastViewingIndex=friendListView.getLastVisiblePosition();
      while (viewingIndex <= lastViewingIndex && viewingIndex <= friends.size()) {
        if (!friends.get(viewingIndex).hasDownloadedProfilePicture()) {
          index=viewingIndex;
          break;
        }
        viewingIndex++;
      }
      return index;
    }
  }
).start();
}

Fixed version (ground truth):
protected void downloadProfilePictures_async(){
  new Thread(new Runnable(){
    @Override public void run(){
      for (int i=0; i < friends.size(); i++) {
        int bestIndex=getBestFriend(i);
        final Friend f=friends.get(bestIndex);
        if (f.hasDownloadedProfilePicture())         continue;
        File file=new File(getCacheDir(),f.getSaveProfiePictureFileName());
        Bitmap picture=Tools.getBitmapFromFile(file);
        if (picture == null) {
          picture=Tools.downloadBitmap(f.getProfilePictureURL());
        }
        if (picture != null) {
          f.setProfilePic(picture);
          Tools.storePictureToFile(file,picture);
        }
        updateProfilePictureAtIndex(f,bestIndex);
        if (bestIndex != i)         i--;
      }
    }
    private void updateProfilePictureAtIndex(    final Friend f,    final int index){
      runOnUiThread(new Runnable(){
        @Override public void run(){
          View v=friendListView.getChildAt(index - friendListView.getFirstVisiblePosition());
          if (v != null) {
            ImageView iv=(ImageView)v.findViewById(R.id.profile_picture);
            if (f.hasDownloadedProfilePicture()) {
              iv.setImageBitmap(f.getProfilePicture());
            }
          }
        }
      }
);
    }
    private int getBestFriend(    int index){
      int viewingIndex=friendListView.getFirstVisiblePosition();
      int lastViewingIndex=friendListView.getLastVisiblePosition();
      while (viewingIndex <= lastViewingIndex && viewingIndex <= friends.size()) {
        if (!friends.get(viewingIndex).hasDownloadedProfilePicture()) {
          index=viewingIndex;
          break;
        }
        viewingIndex++;
      }
      return index;
    }
  }
).start();
}