Program: 42024
Project: 42024
Buggy source:
public void onClick(DialogInterface dialog,int which){
  ResolveInfo ri=mAdapter.resolveInfoForPosition(which);
  Intent intent=mAdapter.intentForPosition(which);
  if ((mAlwaysCheck != null) && mAlwaysCheck.isChecked()) {
    IntentFilter filter=new IntentFilter();
    if (intent.getAction() != null) {
      filter.addAction(intent.getAction());
    }
    Set<String> categories=intent.getCategories();
    if (categories != null) {
      for (      String cat : categories) {
        filter.addCategory(cat);
      }
    }
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    int cat=ri.match & IntentFilter.MATCH_CATEGORY_MASK;
    Uri data=intent.getData();
    if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
      String mimeType=intent.resolveType(this);
      if (mimeType != null) {
        try {
          filter.addDataType(mimeType);
        }
 catch (        IntentFilter.MalformedMimeTypeException e) {
          Log.w("String_Node_Str",e);
          filter=null;
        }
      }
    }
 else     if (data != null && data.getScheme() != null) {
      filter.addDataScheme(data.getScheme());
      Iterator<IntentFilter.AuthorityEntry> aIt=ri.filter.authoritiesIterator();
      if (aIt != null) {
        while (aIt.hasNext()) {
          IntentFilter.AuthorityEntry a=aIt.next();
          if (a.match(data) >= 0) {
            int port=a.getPort();
            filter.addDataAuthority(a.getHost(),port >= 0 ? Integer.toString(port) : null);
            break;
          }
        }
      }
      Iterator<PatternMatcher> pIt=ri.filter.pathsIterator();
      if (pIt != null) {
        String path=data.getPath();
        while (path != null && pIt.hasNext()) {
          PatternMatcher p=pIt.next();
          if (p.match(path)) {
            filter.addDataPath(p.getPath(),p.getType());
            break;
          }
        }
      }
    }
    if (filter != null) {
      final int N=mAdapter.mList.size();
      ComponentName[] set=new ComponentName[N];
      int bestMatch=0;
      for (int i=0; i < N; i++) {
        ResolveInfo r=mAdapter.mList.get(i).ri;
        set[i]=new ComponentName(r.activityInfo.packageName,r.activityInfo.name);
        if (r.match > bestMatch)         bestMatch=r.match;
      }
      getPackageManager().addPreferredActivity(filter,bestMatch,set,intent.getComponent());
    }
  }
  if (intent != null) {
    startActivity(intent);
  }
  finish();
}

Fixed version (ground truth):
public void onClick(DialogInterface dialog,int which){
  ResolveInfo ri=mAdapter.resolveInfoForPosition(which);
  Intent intent=mAdapter.intentForPosition(which);
  if ((mAlwaysCheck != null) && mAlwaysCheck.isChecked()) {
    IntentFilter filter=new IntentFilter();
    if (intent.getAction() != null) {
      filter.addAction(intent.getAction());
    }
    Set<String> categories=intent.getCategories();
    if (categories != null) {
      for (      String cat : categories) {
        filter.addCategory(cat);
      }
    }
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    int cat=ri.match & IntentFilter.MATCH_CATEGORY_MASK;
    Uri data=intent.getData();
    if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
      String mimeType=intent.resolveType(this);
      if (mimeType != null) {
        try {
          filter.addDataType(mimeType);
        }
 catch (        IntentFilter.MalformedMimeTypeException e) {
          Log.w("String_Node_Str",e);
          filter=null;
        }
      }
    }
    if (data != null && data.getScheme() != null) {
      if (cat != IntentFilter.MATCH_CATEGORY_TYPE || (!"String_Node_Str".equals(data.getScheme()) && !"String_Node_Str".equals(data.getScheme()))) {
        filter.addDataScheme(data.getScheme());
        Iterator<IntentFilter.AuthorityEntry> aIt=ri.filter.authoritiesIterator();
        if (aIt != null) {
          while (aIt.hasNext()) {
            IntentFilter.AuthorityEntry a=aIt.next();
            if (a.match(data) >= 0) {
              int port=a.getPort();
              filter.addDataAuthority(a.getHost(),port >= 0 ? Integer.toString(port) : null);
              break;
            }
          }
        }
        Iterator<PatternMatcher> pIt=ri.filter.pathsIterator();
        if (pIt != null) {
          String path=data.getPath();
          while (path != null && pIt.hasNext()) {
            PatternMatcher p=pIt.next();
            if (p.match(path)) {
              filter.addDataPath(p.getPath(),p.getType());
              break;
            }
          }
        }
      }
    }
    if (filter != null) {
      final int N=mAdapter.mList.size();
      ComponentName[] set=new ComponentName[N];
      int bestMatch=0;
      for (int i=0; i < N; i++) {
        ResolveInfo r=mAdapter.mList.get(i).ri;
        set[i]=new ComponentName(r.activityInfo.packageName,r.activityInfo.name);
        if (r.match > bestMatch)         bestMatch=r.match;
      }
      getPackageManager().addPreferredActivity(filter,bestMatch,set,intent.getComponent());
    }
  }
  if (intent != null) {
    startActivity(intent);
  }
  finish();
}