Program: 183987
Project: 183987
Buggy source:
@Override protected void onListItemClick(ListView l,View v,int position,long id){
  hideSoftKeyboard();
  if (mSearchMode && mAdapter.isSearchAllContactsItemPosition(position)) {
    doSearch();
  }
 else   if (mMode == MODE_INSERT_OR_EDIT_CONTACT || mMode == MODE_QUERY_PICK_TO_EDIT) {
    Intent intent;
    if (position == 0 && !mSearchMode && mMode != MODE_QUERY_PICK_TO_EDIT) {
      intent=new Intent(Intent.ACTION_INSERT,Contacts.CONTENT_URI);
    }
 else {
      intent=new Intent(Intent.ACTION_EDIT,getSelectedUri(position));
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    Bundle extras=getIntent().getExtras();
    if (extras != null) {
      intent.putExtras(extras);
    }
    intent.putExtra(KEY_PICKER_MODE,(mMode & MODE_MASK_PICKER) == MODE_MASK_PICKER);
    startActivity(intent);
    finish();
  }
 else   if ((mMode & MODE_MASK_CREATE_NEW) == MODE_MASK_CREATE_NEW && position == 0) {
    Intent newContact=new Intent(Intents.Insert.ACTION,Contacts.CONTENT_URI);
    startActivityForResult(newContact,SUBACTIVITY_NEW_CONTACT);
  }
 else   if (mMode == MODE_JOIN_CONTACT && id == JOIN_MODE_SHOW_ALL_CONTACTS_ID) {
    mJoinModeShowAllContacts=false;
    startQuery();
  }
 else   if (id > 0) {
    final Uri uri=getSelectedUri(position);
    if ((mMode & MODE_MASK_PICKER) == 0) {
      final Intent intent=new Intent(Intent.ACTION_VIEW,uri);
      startActivityForResult(intent,SUBACTIVITY_VIEW_CONTACT);
    }
 else     if (mMode == MODE_JOIN_CONTACT) {
      returnPickerResult(null,null,uri);
    }
 else     if (mMode == MODE_QUERY_PICK_TO_VIEW) {
      final Intent intent=new Intent(Intent.ACTION_VIEW,uri);
      startActivity(intent);
      finish();
    }
 else     if (mMode == MODE_PICK_PHONE || mMode == MODE_QUERY_PICK_PHONE) {
      Cursor c=(Cursor)mAdapter.getItem(position);
      long contactId=c.getLong(PHONE_CONTACT_ID_COLUMN_INDEX);
      returnPickerResult(c,c.getString(PHONE_DISPLAY_NAME_COLUMN_INDEX),ContentUris.withAppendedId(Contacts.CONTENT_URI,contactId));
    }
 else     if ((mMode & MODE_MASK_PICKER) != 0) {
      Cursor c=(Cursor)mAdapter.getItem(position);
      returnPickerResult(c,c.getString(getSummaryDisplayNameColumnIndex()),uri);
    }
 else     if (mMode == MODE_PICK_POSTAL || mMode == MODE_LEGACY_PICK_POSTAL || mMode == MODE_LEGACY_PICK_PHONE) {
      returnPickerResult(null,null,uri);
    }
  }
 else {
    signalError();
  }
}

Fixed version (ground truth):
@Override protected void onListItemClick(ListView l,View v,int position,long id){
  hideSoftKeyboard();
  if (mSearchMode && mAdapter.isSearchAllContactsItemPosition(position)) {
    doSearch();
  }
 else   if (mMode == MODE_INSERT_OR_EDIT_CONTACT || mMode == MODE_QUERY_PICK_TO_EDIT) {
    Intent intent;
    if (position == 0 && !mSearchMode && mMode != MODE_QUERY_PICK_TO_EDIT) {
      intent=new Intent(Intent.ACTION_INSERT,Contacts.CONTENT_URI);
    }
 else {
      intent=new Intent(Intent.ACTION_EDIT,getSelectedUri(position));
    }
    intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    Bundle extras=getIntent().getExtras();
    if (extras != null) {
      intent.putExtras(extras);
    }
    intent.putExtra(KEY_PICKER_MODE,(mMode & MODE_MASK_PICKER) == MODE_MASK_PICKER);
    startActivity(intent);
    finish();
  }
 else   if ((mMode & MODE_MASK_CREATE_NEW) == MODE_MASK_CREATE_NEW && position == 0) {
    Intent newContact=new Intent(Intents.Insert.ACTION,Contacts.CONTENT_URI);
    startActivityForResult(newContact,SUBACTIVITY_NEW_CONTACT);
  }
 else   if (mMode == MODE_JOIN_CONTACT && id == JOIN_MODE_SHOW_ALL_CONTACTS_ID) {
    mJoinModeShowAllContacts=false;
    startQuery();
  }
 else   if (id > 0) {
    final Uri uri=getSelectedUri(position);
    if ((mMode & MODE_MASK_PICKER) == 0) {
      final Intent intent=new Intent(Intent.ACTION_VIEW,uri);
      startActivityForResult(intent,SUBACTIVITY_VIEW_CONTACT);
    }
 else     if (mMode == MODE_JOIN_CONTACT) {
      returnPickerResult(null,null,uri);
    }
 else     if (mMode == MODE_QUERY_PICK_TO_VIEW) {
      final Intent intent=new Intent(Intent.ACTION_VIEW,uri);
      startActivity(intent);
      finish();
    }
 else     if (mMode == MODE_PICK_PHONE || mMode == MODE_QUERY_PICK_PHONE) {
      Cursor c=(Cursor)mAdapter.getItem(position);
      returnPickerResult(c,c.getString(PHONE_DISPLAY_NAME_COLUMN_INDEX),uri);
    }
 else     if ((mMode & MODE_MASK_PICKER) != 0) {
      Cursor c=(Cursor)mAdapter.getItem(position);
      returnPickerResult(c,c.getString(getSummaryDisplayNameColumnIndex()),uri);
    }
 else     if (mMode == MODE_PICK_POSTAL || mMode == MODE_LEGACY_PICK_POSTAL || mMode == MODE_LEGACY_PICK_PHONE) {
      returnPickerResult(null,null,uri);
    }
  }
 else {
    signalError();
  }
}