Program: 84973
Project: 84973
Buggy source:
private void updateCompletedNotification(){
  Cursor cursor=mContext.getContentResolver().query(BluetoothShare.CONTENT_URI,null,WHERE_COMPLETED,null,BluetoothShare._ID);
  if (cursor == null) {
    return;
  }
  for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
    int timeStamp=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
    int dir=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.DIRECTION));
    int id=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare._ID));
    int status=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.STATUS));
    String fileName=cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare._DATA));
    if (fileName == null) {
      fileName=cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.FILENAME_HINT));
    }
    if (fileName == null) {
      fileName=mContext.getString(R.string.unknown_file);
    }
    String title;
    String caption;
    Uri contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + id);
    Notification n=new Notification();
    if (BluetoothShare.isStatusError(status)) {
      if (dir == BluetoothShare.DIRECTION_OUTBOUND) {
        title=mContext.getString(R.string.notification_sent_fail).replace("String_Node_Str",fileName);
      }
 else {
        title=mContext.getString(R.string.notification_received_fail).replace("String_Node_Str",fileName);
      }
      caption=mContext.getString(R.string.download_fail_line3).replace("String_Node_Str",BluetoothOppUtility.getStatusDescription(mContext,status));
      n.icon=android.R.drawable.stat_notify_error;
    }
 else {
      if (dir == BluetoothShare.DIRECTION_OUTBOUND) {
        title=mContext.getString(R.string.notification_sent).replace("String_Node_Str",fileName);
        n.icon=android.R.drawable.stat_sys_upload_done;
      }
 else {
        title=mContext.getString(R.string.notification_received).replace("String_Node_Str",fileName);
        n.icon=android.R.drawable.stat_sys_download_done;
      }
      caption=mContext.getString(R.string.notification_sent_complete);
    }
    Intent intent=new Intent(Constants.ACTION_OPEN);
    intent.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    intent.setData(contentUri);
    n.setLatestEventInfo(mContext,title,caption,PendingIntent.getBroadcast(mContext,0,intent,0));
    intent=new Intent(Constants.ACTION_HIDE);
    intent.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    intent.setData(contentUri);
    n.deleteIntent=PendingIntent.getBroadcast(mContext,0,intent,0);
    n.when=timeStamp;
    mNotificationMgr.notify(id,n);
  }
  cursor.close();
}

Fixed version (ground truth):
private void updateCompletedNotification(){
  Cursor cursor=mContext.getContentResolver().query(BluetoothShare.CONTENT_URI,null,WHERE_COMPLETED,null,BluetoothShare._ID);
  if (cursor == null) {
    return;
  }
  for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
    int timeStamp=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.TIMESTAMP));
    int dir=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.DIRECTION));
    int id=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare._ID));
    int status=cursor.getInt(cursor.getColumnIndexOrThrow(BluetoothShare.STATUS));
    String fileName=cursor.getString(cursor.getColumnIndexOrThrow(BluetoothShare.FILENAME_HINT));
    if (fileName == null) {
      fileName=mContext.getString(R.string.unknown_file);
    }
    String title;
    String caption;
    Uri contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + id);
    Notification n=new Notification();
    if (BluetoothShare.isStatusError(status)) {
      if (dir == BluetoothShare.DIRECTION_OUTBOUND) {
        title=mContext.getString(R.string.notification_sent_fail).replace("String_Node_Str",fileName);
      }
 else {
        title=mContext.getString(R.string.notification_received_fail).replace("String_Node_Str",fileName);
      }
      caption=mContext.getString(R.string.download_fail_line3).replace("String_Node_Str",BluetoothOppUtility.getStatusDescription(mContext,status));
      n.icon=android.R.drawable.stat_notify_error;
    }
 else {
      if (dir == BluetoothShare.DIRECTION_OUTBOUND) {
        title=mContext.getString(R.string.notification_sent).replace("String_Node_Str",fileName);
        n.icon=android.R.drawable.stat_sys_upload_done;
      }
 else {
        title=mContext.getString(R.string.notification_received).replace("String_Node_Str",fileName);
        n.icon=android.R.drawable.stat_sys_download_done;
      }
      caption=mContext.getString(R.string.notification_sent_complete);
    }
    Intent intent=new Intent(Constants.ACTION_OPEN);
    intent.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    intent.setData(contentUri);
    n.setLatestEventInfo(mContext,title,caption,PendingIntent.getBroadcast(mContext,0,intent,0));
    intent=new Intent(Constants.ACTION_HIDE);
    intent.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    intent.setData(contentUri);
    n.deleteIntent=PendingIntent.getBroadcast(mContext,0,intent,0);
    n.when=timeStamp;
    mNotificationMgr.notify(id,n);
  }
  cursor.close();
}