Program: 110076
Project: 110076
Buggy source:
public static AlertDialog buildSelectPlaylistDialog(final DB db,final Context context,final int diagTitle,final String[] userMenuStrings,final OnPlaylistSelectedListener action,long excludedPlid,final Object user){
  final String[] userMenus=(null == userMenuStrings) ? new String[0] : userMenuStrings;
  final Cursor c=db.queryPlaylist(new DB.ColPlaylist[]{DB.ColPlaylist.ID,DB.ColPlaylist.TITLE});
  final int iTitle=c.getColumnIndex(DB.ColPlaylist.TITLE.getName());
  final int iId=c.getColumnIndex(DB.ColPlaylist.ID.getName());
  LinkedList<String> menul=new LinkedList<String>();
  LinkedList<Long> idl=new LinkedList<Long>();
  for (int i=0; i < userMenus.length; i++) {
    menul.add(userMenus[i]);
    idl.add((long)i);
  }
  menul.add(context.getResources().getText(R.string.new_playlist).toString());
  idl.add((long)userMenus.length);
  if (c.moveToFirst()) {
    do {
      if (excludedPlid != c.getLong(iId)) {
        menul.add(c.getString(iTitle));
        idl.add(c.getLong(iId));
      }
    }
 while (c.moveToNext());
  }
  c.close();
  final String[] menus=menul.toArray(new String[0]);
  final long[] ids=Utils.convertArrayLongTolong(idl.toArray(new Long[0]));
  AlertDialog.Builder bldr=new AlertDialog.Builder(context);
  if (diagTitle > 0)   bldr.setTitle(diagTitle);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(context,android.R.layout.select_dialog_item,menus);
  bldr.setAdapter(adapter,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      eAssert(which >= 0);
      dialog.dismiss();
      if (userMenus.length > which) {
        action.onUserMenu(which,user);
      }
 else       if (userMenus.length == which) {
        UiUtils.EditTextAction edAction=new UiUtils.EditTextAction(){
          @Override public void prepare(          Dialog dialog,          EditText edit){
          }
          @Override public void onOk(          Dialog dialog,          EditText edit){
            String title=edit.getText().toString();
            if (db.containsPlaylist(title)) {
              UiUtils.showTextToast(context,R.string.msg_existing_playlist);
              return;
            }
            long plid=db.insertPlaylist(title,"String_Node_Str");
            if (plid < 0) {
              UiUtils.showTextToast(context,R.string.err_db_unknown);
              return;
            }
            action.onPlaylist(plid,user);
          }
        }
;
        AlertDialog diag=UiUtils.buildOneLineEditTextDialog(context,R.string.enter_playlist_title,R.string.enter_playlist_title,edAction);
        diag.show();
      }
 else       action.onPlaylist(ids[which],user);
    }
  }
);
  return bldr.create();
}

Fixed version (ground truth):
public static AlertDialog buildSelectPlaylistDialog(final DB db,final Context context,final int diagTitle,final String[] userMenuStrings,final OnPlaylistSelectedListener action,long excludedPlid,final Object user){
  final String[] userMenus=(null == userMenuStrings) ? new String[0] : userMenuStrings;
  final Cursor c=db.queryPlaylist(new DB.ColPlaylist[]{DB.ColPlaylist.ID,DB.ColPlaylist.TITLE});
  final int iTitle=c.getColumnIndex(DB.ColPlaylist.TITLE.getName());
  final int iId=c.getColumnIndex(DB.ColPlaylist.ID.getName());
  LinkedList<String> menul=new LinkedList<String>();
  LinkedList<Long> idl=new LinkedList<Long>();
  for (int i=0; i < userMenus.length; i++) {
    menul.add(userMenus[i]);
    idl.add((long)i);
  }
  menul.add(context.getResources().getText(R.string.new_playlist).toString());
  idl.add((long)userMenus.length);
  if (c.moveToFirst()) {
    do {
      if (excludedPlid != c.getLong(iId)) {
        menul.add(c.getString(iTitle));
        idl.add(c.getLong(iId));
      }
    }
 while (c.moveToNext());
  }
  c.close();
  final String[] menus=menul.toArray(new String[0]);
  final long[] ids=Utils.convertArrayLongTolong(idl.toArray(new Long[0]));
  AlertDialog.Builder bldr=new AlertDialog.Builder(context);
  if (diagTitle > 0)   bldr.setTitle(diagTitle);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(context,android.R.layout.select_dialog_item,menus);
  bldr.setAdapter(adapter,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialog,    int which){
      eAssert(which >= 0);
      dialog.dismiss();
      if (userMenus.length > which) {
        action.onUserMenu(which,user);
      }
 else       if (userMenus.length == which) {
        UiUtils.EditTextAction edAction=new UiUtils.EditTextAction(){
          @Override public void prepare(          Dialog dialog,          EditText edit){
          }
          @Override public void onOk(          Dialog dialog,          EditText edit){
            String title=edit.getText().toString();
            if (db.containsPlaylist(title)) {
              UiUtils.showTextToast(context,R.string.msg_existing_playlist);
              return;
            }
            long plid=db.insertPlaylist(title,"String_Node_Str");
            if (plid < 0) {
              UiUtils.showTextToast(context,R.string.err_db_unknown);
              return;
            }
            action.onPlaylist(plid,user);
          }
        }
;
        UiUtils.buildOneLineEditTextDialog(context,R.string.enter_playlist_title,R.string.enter_playlist_title,edAction).show();
      }
 else       action.onPlaylist(ids[which],user);
    }
  }
);
  return bldr.create();
}