Program: 1307
Project: 1307
Buggy source:
private void rebuildList(){
  List<ResolveInfo> currentResolveList;
  try {
    mLastChosen=AppGlobals.getPackageManager().getLastChosenActivity(mIntent,mIntent.resolveTypeIfNeeded(getContentResolver()),PackageManager.MATCH_DEFAULT_ONLY);
  }
 catch (  RemoteException re) {
    Log.d(TAG,"String_Node_Str" + re);
  }
  mList.clear();
  if (mBaseResolveList != null) {
    currentResolveList=mBaseResolveList;
  }
 else {
    currentResolveList=mPm.queryIntentActivities(mIntent,PackageManager.MATCH_DEFAULT_ONLY | (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0));
    if (currentResolveList != null) {
      for (int i=currentResolveList.size() - 1; i >= 0; i--) {
        ActivityInfo ai=currentResolveList.get(i).activityInfo;
        int granted=ActivityManager.checkComponentPermission(ai.permission,mLaunchedFromUid,ai.applicationInfo.uid,ai.exported);
        if (granted != PackageManager.PERMISSION_GRANTED) {
          currentResolveList.remove(i);
        }
      }
    }
  }
  int N;
  if ((currentResolveList != null) && ((N=currentResolveList.size()) > 0)) {
    ResolveInfo r0=currentResolveList.get(0);
    for (int i=1; i < N; i++) {
      ResolveInfo ri=currentResolveList.get(i);
      if (DEBUG)       Log.v("String_Node_Str",r0.activityInfo.name + "String_Node_Str" + r0.priority+ "String_Node_Str"+ r0.isDefault+ "String_Node_Str"+ ri.activityInfo.name+ "String_Node_Str"+ ri.priority+ "String_Node_Str"+ ri.isDefault);
      if (r0.priority != ri.priority || r0.isDefault != ri.isDefault) {
        while (i < N) {
          currentResolveList.remove(i);
          N--;
        }
      }
    }
    if (N > 1) {
      ResolveInfo.DisplayNameComparator rComparator=new ResolveInfo.DisplayNameComparator(mPm);
      Collections.sort(currentResolveList,rComparator);
    }
    if (mInitialIntents != null) {
      for (int i=0; i < mInitialIntents.length; i++) {
        Intent ii=mInitialIntents[i];
        if (ii == null) {
          continue;
        }
        ActivityInfo ai=ii.resolveActivityInfo(getPackageManager(),0);
        if (ai == null) {
          Log.w("String_Node_Str","String_Node_Str" + ii);
          continue;
        }
        ResolveInfo ri=new ResolveInfo();
        ri.activityInfo=ai;
        if (ii instanceof LabeledIntent) {
          LabeledIntent li=(LabeledIntent)ii;
          ri.resolvePackageName=li.getSourcePackage();
          ri.labelRes=li.getLabelResource();
          ri.nonLocalizedLabel=li.getNonLocalizedLabel();
          ri.icon=li.getIconResource();
        }
        mList.add(new DisplayResolveInfo(ri,ri.loadLabel(getPackageManager()),null,ii));
      }
    }
    r0=currentResolveList.get(0);
    int start=0;
    CharSequence r0Label=r0.loadLabel(mPm);
    mShowExtended=false;
    for (int i=1; i < N; i++) {
      if (r0Label == null) {
        r0Label=r0.activityInfo.packageName;
      }
      ResolveInfo ri=currentResolveList.get(i);
      CharSequence riLabel=ri.loadLabel(mPm);
      if (riLabel == null) {
        riLabel=ri.activityInfo.packageName;
      }
      if (riLabel.equals(r0Label)) {
        continue;
      }
      processGroup(currentResolveList,start,(i - 1),r0,r0Label);
      r0=ri;
      r0Label=riLabel;
      start=i;
    }
    processGroup(currentResolveList,start,(N - 1),r0,r0Label);
  }
}

Fixed version (ground truth):
private void rebuildList(){
  List<ResolveInfo> currentResolveList;
  try {
    mLastChosen=AppGlobals.getPackageManager().getLastChosenActivity(mIntent,mIntent.resolveTypeIfNeeded(getContentResolver()),PackageManager.MATCH_DEFAULT_ONLY);
  }
 catch (  RemoteException re) {
    Log.d(TAG,"String_Node_Str" + re);
  }
  mList.clear();
  if (mBaseResolveList != null) {
    currentResolveList=mBaseResolveList;
    mOrigResolveList=null;
  }
 else {
    currentResolveList=mOrigResolveList=mPm.queryIntentActivities(mIntent,PackageManager.MATCH_DEFAULT_ONLY | (mAlwaysUseOption ? PackageManager.GET_RESOLVED_FILTER : 0));
    if (currentResolveList != null) {
      for (int i=currentResolveList.size() - 1; i >= 0; i--) {
        ActivityInfo ai=currentResolveList.get(i).activityInfo;
        int granted=ActivityManager.checkComponentPermission(ai.permission,mLaunchedFromUid,ai.applicationInfo.uid,ai.exported);
        if (granted != PackageManager.PERMISSION_GRANTED) {
          if (mOrigResolveList == currentResolveList) {
            mOrigResolveList=new ArrayList<ResolveInfo>(mOrigResolveList);
          }
          currentResolveList.remove(i);
        }
      }
    }
  }
  int N;
  if ((currentResolveList != null) && ((N=currentResolveList.size()) > 0)) {
    ResolveInfo r0=currentResolveList.get(0);
    for (int i=1; i < N; i++) {
      ResolveInfo ri=currentResolveList.get(i);
      if (DEBUG)       Log.v("String_Node_Str",r0.activityInfo.name + "String_Node_Str" + r0.priority+ "String_Node_Str"+ r0.isDefault+ "String_Node_Str"+ ri.activityInfo.name+ "String_Node_Str"+ ri.priority+ "String_Node_Str"+ ri.isDefault);
      if (r0.priority != ri.priority || r0.isDefault != ri.isDefault) {
        while (i < N) {
          if (mOrigResolveList == currentResolveList) {
            mOrigResolveList=new ArrayList<ResolveInfo>(mOrigResolveList);
          }
          currentResolveList.remove(i);
          N--;
        }
      }
    }
    if (N > 1) {
      ResolveInfo.DisplayNameComparator rComparator=new ResolveInfo.DisplayNameComparator(mPm);
      Collections.sort(currentResolveList,rComparator);
    }
    if (mInitialIntents != null) {
      for (int i=0; i < mInitialIntents.length; i++) {
        Intent ii=mInitialIntents[i];
        if (ii == null) {
          continue;
        }
        ActivityInfo ai=ii.resolveActivityInfo(getPackageManager(),0);
        if (ai == null) {
          Log.w("String_Node_Str","String_Node_Str" + ii);
          continue;
        }
        ResolveInfo ri=new ResolveInfo();
        ri.activityInfo=ai;
        if (ii instanceof LabeledIntent) {
          LabeledIntent li=(LabeledIntent)ii;
          ri.resolvePackageName=li.getSourcePackage();
          ri.labelRes=li.getLabelResource();
          ri.nonLocalizedLabel=li.getNonLocalizedLabel();
          ri.icon=li.getIconResource();
        }
        mList.add(new DisplayResolveInfo(ri,ri.loadLabel(getPackageManager()),null,ii));
      }
    }
    r0=currentResolveList.get(0);
    int start=0;
    CharSequence r0Label=r0.loadLabel(mPm);
    mShowExtended=false;
    for (int i=1; i < N; i++) {
      if (r0Label == null) {
        r0Label=r0.activityInfo.packageName;
      }
      ResolveInfo ri=currentResolveList.get(i);
      CharSequence riLabel=ri.loadLabel(mPm);
      if (riLabel == null) {
        riLabel=ri.activityInfo.packageName;
      }
      if (riLabel.equals(r0Label)) {
        continue;
      }
      processGroup(currentResolveList,start,(i - 1),r0,r0Label);
      r0=ri;
      r0Label=riLabel;
      start=i;
    }
    processGroup(currentResolveList,start,(N - 1),r0,r0Label);
  }
}