Program: 17531
Project: 17531
Buggy source:
@Override public boolean onMenuItemClick(MenuItem menuItem){
  final CharSequence text=((AppCompatTextView)v).getText();
  try {
    final String FileName=text.toString();
    final AppCompatDialog dialog=new AppCompatDialog(activity);
    dialog.setTitle(R.string.setname);
    dialog.setContentView(R.layout.dialog_input);
    final AppCompatButton bGo=(AppCompatButton)dialog.findViewById(R.id.bGoBackup);
    final AppCompatEditText etFileName=(AppCompatEditText)dialog.findViewById(R.id.etFileName);
    final File path=isRecovery ? Const.PathToRecoveryBackups : Const.PathToKernelBackups;
switch (menuItem.getItemId()) {
case R.id.iRestore:
      FlashUtil RestoreUtil=new FlashUtil(activity,new File(path,FileName),isRecovery ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
    RestoreUtil.execute();
  return true;
case R.id.iRename:
etFileName.setHint(FileName);
bGo.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v){
  String Name;
  if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("String_Node_Str")) {
    Name=etFileName.getText().toString();
  }
 else {
    Name=String.valueOf(etFileName.getHint());
  }
  if (!Name.endsWith(activity.getDevice().getRecoveryExt())) {
    Name=Name + activity.getDevice().getRecoveryExt();
  }
  File renamedBackup=new File(path,Name);
  if (renamedBackup.exists()) {
    Toast.makeText(activity,R.string.backupalready,Toast.LENGTH_SHORT).show();
  }
 else {
    File Backup=new File(path,FileName);
    if (Backup.renameTo(renamedBackup)) {
      loadBackups(activity.getDevice(),adapter,isRecovery);
    }
 else {
      Toast.makeText(activity,R.string.rename_failed,Toast.LENGTH_SHORT).show();
    }
  }
  dialog.dismiss();
}
}
);
dialog.show();
return true;
case R.id.iDeleteBackup:
if (new File(path,text.toString()).delete()) {
Toast.makeText(activity,activity.getString(R.string.bak_deleted),Toast.LENGTH_SHORT).show();
ArrayAdapter<String> adapter;
if (isRecovery) {
adapter=pagerAdapter.getRecoveryBackupFragment().getAdapter();
}
 else {
adapter=pagerAdapter.getKernelBackupFragment().getAdapter();
}
loadBackups(activity.getDevice(),adapter,isRecovery);
}
return true;
default :
return false;
}
}
 catch (Exception e) {
if (e.getMessage().contains("String_Node_Str") && text.toString().contains("String_Node_Str")) {
AlertDialog.Builder adialog=new AlertDialog.Builder(activity);
adialog.setMessage(R.string.check_name);
adialog.setMessage(R.string.ok);
adialog.show();
}
activity.addError(Const.RASHR_TAG,e,false);
return false;
}
}

Fixed version (ground truth):
@Override public boolean onMenuItemClick(final MenuItem menuItem){
  final CharSequence text=((AppCompatTextView)v).getText();
  final String FileName=text.toString();
  final AppCompatDialog dialog=new AppCompatDialog(mActivity);
  dialog.setTitle(R.string.setname);
  dialog.setContentView(R.layout.dialog_input);
  final AppCompatButton bGo=(AppCompatButton)dialog.findViewById(R.id.bGoBackup);
  final AppCompatEditText etFileName=(AppCompatEditText)dialog.findViewById(R.id.etFileName);
  final File path=mPager.getCurrentItem() == 0 ? Const.PathToRecoveryBackups : Const.PathToKernelBackups;
  try {
switch (menuItem.getItemId()) {
case R.id.iRestore:
      File backup=new File(path,FileName);
    FlashUtil RestoreUtil=new FlashUtil(mActivity,backup,mPager.getCurrentItem() == 1 ? FlashUtil.JOB_RESTORE_RECOVERY : FlashUtil.JOB_RESTORE_KERNEL);
  RestoreUtil.execute();
return true;
case R.id.iRename:
etFileName.setHint(FileName);
bGo.setOnClickListener(new View.OnClickListener(){
@Override public void onClick(View v){
String Name;
if (etFileName.getText() != null && etFileName.isEnabled() && !etFileName.getText().toString().equals("String_Node_Str")) {
  Name=etFileName.getText().toString();
}
 else {
  Name=String.valueOf(etFileName.getHint());
}
if (!Name.endsWith(mDevice.getRecoveryExt())) {
  Name+=mDevice.getRecoveryExt();
}
File renamedBackup=new File(path,Name);
if (renamedBackup.exists()) {
  Toast.makeText(mActivity,R.string.backupalready,Toast.LENGTH_SHORT).show();
  onMenuItemClick(menuItem);
}
 else {
  File Backup=new File(path,FileName);
  if (Backup.renameTo(renamedBackup)) {
    mAdapter.reload();
  }
 else {
    Toast.makeText(mActivity,R.string.rename_failed,Toast.LENGTH_SHORT).show();
  }
}
dialog.dismiss();
}
}
);
dialog.show();
return true;
case R.id.iDeleteBackup:
backup=new File(path,text.toString());
if (backup.delete()) {
Toast.makeText(mActivity,mContext.getString(R.string.bak_deleted),Toast.LENGTH_SHORT).show();
}
mAdapter.reload();
return true;
default :
return false;
}
}
 catch (Exception e) {
if (e.getMessage().contains("String_Node_Str") && text.toString().contains("String_Node_Str")) {
AlertDialog.Builder adialog=new AlertDialog.Builder(mContext);
adialog.setMessage(R.string.check_name);
adialog.setMessage(R.string.ok);
adialog.show();
}
mActivity.addError(Const.RASHR_TAG,e.toString(),false);
return false;
}
}