Program: 172525
Project: 172525
Buggy source:
public void sendSMS(String message){
  PendingIntent sentPI=PendingIntent.getBroadcast(context,0,new Intent(SENT),0);
  PendingIntent deliveredPI=PendingIntent.getBroadcast(context,0,new Intent(DELIVERED),0);
  BroadcastReceiver mySender=new BroadcastReceiver(){
    @Override public void onReceive(    Context arg0,    Intent arg1){
switch (getResultCode()) {
case Activity.RESULT_OK:
        context.unregisterReceiver(this);
      if (mySmsManagerCallBack != null)       mySmsManagerCallBack.afterSuccessfulSMS(smsId);
    break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
  context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
}
}
}
;
context.registerReceiver(mySender,new IntentFilter(SENT));
BroadcastReceiver myReceiver=new BroadcastReceiver(){
@Override public void onReceive(Context arg0,Intent arg1){
switch (getResultCode()) {
case Activity.RESULT_OK:
context.unregisterReceiver(this);
mySmsManagerCallBack.afterDelivered(smsId);
break;
case Activity.RESULT_CANCELED:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
}
}
}
;
context.registerReceiver(myReceiver,new IntentFilter(DELIVERED));
SmsManager sms=SmsManager.getDefault();
int subscriptionId=carrierSlotNumber;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1 && carrierSlotCount > 1) {
if (checkCarrierNameFilter()) {
sms.getSmsManagerForSubscriptionId(subscriptionId).sendTextMessage(sms_number,null,message,sentPI,deliveredPI);
}
 else {
mySmsManagerCallBack.onCarrierNameNotMatch(smsId,"String_Node_Str" + carrierNameFilter);
}
}
 else {
if (checkCarrierNameFilter()) {
sms.sendTextMessage(sms_number,null,message,sentPI,deliveredPI);
}
 else {
mySmsManagerCallBack.onCarrierNameNotMatch(smsId,"String_Node_Str" + carrierNameFilter);
}
}
}

Fixed version (ground truth):
public void sendSMS(String message){
  PendingIntent sentPI=PendingIntent.getBroadcast(context,0,new Intent(SENT),0);
  PendingIntent deliveredPI=PendingIntent.getBroadcast(context,0,new Intent(DELIVERED),0);
  BroadcastReceiver mySender=new BroadcastReceiver(){
    @Override public void onReceive(    Context arg0,    Intent arg1){
switch (getResultCode()) {
case Activity.RESULT_OK:
        context.unregisterReceiver(this);
      if (mySmsManagerCallBack != null)       mySmsManagerCallBack.afterSuccessfulSMS(smsId);
    break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
  context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
}
}
}
;
context.registerReceiver(mySender,new IntentFilter(SENT));
BroadcastReceiver myReceiver=new BroadcastReceiver(){
@Override public void onReceive(Context arg0,Intent arg1){
switch (getResultCode()) {
case Activity.RESULT_OK:
context.unregisterReceiver(this);
mySmsManagerCallBack.afterDelivered(smsId);
break;
case Activity.RESULT_CANCELED:
context.unregisterReceiver(this);
if (mySmsManagerCallBack != null) mySmsManagerCallBack.afterUnSuccessfulSMS(smsId,"String_Node_Str");
break;
}
}
}
;
context.registerReceiver(myReceiver,new IntentFilter(DELIVERED));
SmsManager sms=SmsManager.getDefault();
int subscriptionId=carrierSlotNumber;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {
if (checkCarrierNameFilter()) {
if (carrierSlotCount > 1) {
sendSms(message,sentPI,deliveredPI,sms.getSmsManagerForSubscriptionId(subscriptionId));
}
 else {
sendSms(message,sentPI,deliveredPI,sms);
}
}
 else {
mySmsManagerCallBack.onCarrierNameNotMatch(smsId,"String_Node_Str" + carrierNameFilter);
}
}
 else {
sendSms(message,sentPI,deliveredPI,sms);
}
}