Program: 38345
Project: 38345
Buggy source:
public ArrayList<Path> getSelected(boolean expandSet,int maxSelection){
  ArrayList<Path> selected=new ArrayList<Path>();
  if (mIsAlbumSet) {
    if (mInverseSelection) {
      int total=getTotalCount();
      for (int i=0; i < total; i++) {
        MediaSet set=mSourceMediaSet.getSubMediaSet(i);
        Path id=set.getPath();
        if (!mClickedSet.contains(id)) {
          if (expandSet && !expandMediaSet(selected,set,maxSelection)) {
            return null;
          }
 else {
            selected.add(id);
            if (selected.size() > maxSelection) {
              return null;
            }
          }
        }
      }
    }
 else {
      for (      Path id : mClickedSet) {
        if (expandSet && !expandMediaSet(selected,mDataManager.getMediaSet(id),maxSelection)) {
          return null;
        }
 else {
          selected.add(id);
          if (selected.size() > maxSelection) {
            return null;
          }
        }
      }
    }
  }
 else {
    if (mInverseSelection) {
      int total=getTotalCount();
      int index=0;
      while (index < total) {
        int count=Math.min(total - index,MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
        ArrayList<MediaItem> list=mSourceMediaSet.getMediaItem(index,count);
        for (        MediaItem item : list) {
          Path id=item.getPath();
          if (!mClickedSet.contains(id)) {
            selected.add(id);
            if (selected.size() > maxSelection) {
              return null;
            }
          }
        }
        index+=count;
      }
    }
 else {
      for (      Path id : mClickedSet) {
        selected.add(id);
        if (selected.size() > maxSelection) {
          return null;
        }
      }
    }
  }
  return selected;
}

Fixed version (ground truth):
public ArrayList<Path> getSelected(boolean expandSet,int maxSelection){
  ArrayList<Path> selected=new ArrayList<Path>();
  if (mIsAlbumSet) {
    if (mInverseSelection) {
      int total=getTotalCount();
      for (int i=0; i < total; i++) {
        MediaSet set=mSourceMediaSet.getSubMediaSet(i);
        Path id=set.getPath();
        if (!mClickedSet.contains(id)) {
          if (expandSet) {
            if (!expandMediaSet(selected,set,maxSelection)) {
              return null;
            }
          }
 else {
            selected.add(id);
            if (selected.size() > maxSelection) {
              return null;
            }
          }
        }
      }
    }
 else {
      for (      Path id : mClickedSet) {
        if (expandSet) {
          if (!expandMediaSet(selected,mDataManager.getMediaSet(id),maxSelection)) {
            return null;
          }
        }
 else {
          selected.add(id);
          if (selected.size() > maxSelection) {
            return null;
          }
        }
      }
    }
  }
 else {
    if (mInverseSelection) {
      int total=getTotalCount();
      int index=0;
      while (index < total) {
        int count=Math.min(total - index,MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
        ArrayList<MediaItem> list=mSourceMediaSet.getMediaItem(index,count);
        for (        MediaItem item : list) {
          Path id=item.getPath();
          if (!mClickedSet.contains(id)) {
            selected.add(id);
            if (selected.size() > maxSelection) {
              return null;
            }
          }
        }
        index+=count;
      }
    }
 else {
      for (      Path id : mClickedSet) {
        selected.add(id);
        if (selected.size() > maxSelection) {
          return null;
        }
      }
    }
  }
  return selected;
}