Program: 187354
Project: 187354
Buggy source:
private String handleEncryptedMessage(Context context,String address,String fullMessage){
  String secretMessage=null;
  if (dba.isTrustedContact((address)) && ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.ENABLE_SETTING_KEY,true)) {
    Message encryMessage=null;
    try {
      SMSUtility.sendToSelf(context,address,fullMessage,ConversationView.INBOX);
      Message newMessage=null;
      Log.v("String_Node_Str",fullMessage);
      Encryption CryptoEngine=new Encryption();
      Number contactNumber=dba.getNumber(SMSUtility.format(address));
      secretMessage=CryptoEngine.decrypt(contactNumber,fullMessage);
      Log.v("String_Node_Str",secretMessage);
      dba.updateDecryptNonce(contactNumber);
      if (ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.SHOW_ENCRYPT_SETTING_KEY,false)) {
        encryMessage=new Message(fullMessage,true,Message.RECEIVED_ENCRYPTED);
        dba.addNewMessage(encryMessage,address,true);
      }
      SMSUtility.sendToSelf(context,address,secretMessage,ConversationView.INBOX);
      newMessage=new Message(secretMessage,true,Message.RECEIVED_ENCRYPTED);
      dba.addNewMessage(newMessage,address,true);
    }
 catch (    InvalidCipherTextException e) {
      encryMessage=new Message(fullMessage,true,Message.RECEIVED_ENCRYPT_FAIL);
      dba.addNewMessage(encryMessage,address,true);
      Toast.makeText(context,R.string.key_exchange_failed_to_decrypt,Toast.LENGTH_LONG).show();
      Toast.makeText(context,R.string.possible_man_in_the_middle_attack_warning,Toast.LENGTH_LONG).show();
      e.printStackTrace();
      BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    }
catch (    Exception e) {
      e.printStackTrace();
      BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    }
  }
  return secretMessage;
}

Fixed version (ground truth):
private String handleEncryptedMessage(Context context,String address,String fullMessage){
  String secretMessage=null;
  if (dba.isTrustedContact((address)) && ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.ENABLE_SETTING_KEY,true)) {
    Message encryMessage=null;
    try {
      SMSUtility.sendToSelf(context,address,fullMessage,ConversationView.INBOX);
      Message newMessage=null;
      Log.v("String_Node_Str",fullMessage);
      if (SMSUtility.cryptoEngine == null) {
        SMSUtility.cryptoEngine=new Encryption(SMSUtility.getUser(dba,null));
      }
      Number contactNumber=dba.getNumber(SMSUtility.format(address));
      secretMessage=SMSUtility.cryptoEngine.decrypt(contactNumber,fullMessage);
      Log.v("String_Node_Str",secretMessage);
      dba.updateDecryptNonce(contactNumber);
      if (ConversationView.sharedPrefs.getBoolean(QuickPrefsActivity.SHOW_ENCRYPT_SETTING_KEY,false)) {
        encryMessage=new Message(fullMessage,true,Message.RECEIVED_ENCRYPTED);
        dba.addNewMessage(encryMessage,address,true);
      }
      SMSUtility.sendToSelf(context,address,secretMessage,ConversationView.INBOX);
      newMessage=new Message(secretMessage,true,Message.RECEIVED_ENCRYPTED);
      dba.addNewMessage(newMessage,address,true);
    }
 catch (    InvalidCipherTextException e) {
      encryMessage=new Message(fullMessage,true,Message.RECEIVED_ENCRYPT_FAIL);
      dba.addNewMessage(encryMessage,address,true);
      Toast.makeText(context,R.string.key_exchange_failed_to_decrypt,Toast.LENGTH_LONG).show();
      Toast.makeText(context,R.string.possible_man_in_the_middle_attack_warning,Toast.LENGTH_LONG).show();
      e.printStackTrace();
      BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    }
catch (    Exception e) {
      e.printStackTrace();
      BugSenseHandler.sendExceptionMessage("String_Node_Str","String_Node_Str",e);
    }
  }
  return secretMessage;
}