Program: 84951
Project: 84951
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()) {
    long timeStamp=cursor.getLong(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,fileName);
      }
 else {
        title=mContext.getString(R.string.notification_received_fail,fileName);
      }
      caption=mContext.getString(R.string.download_fail_line3,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,fileName);
        n.icon=android.R.drawable.stat_sys_upload_done;
      }
 else {
        title=mContext.getString(R.string.notification_received,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()) {
    long timeStamp=cursor.getLong(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,fileName);
      }
 else {
        title=mContext.getString(R.string.notification_received_fail,fileName);
      }
      caption=mContext.getString(R.string.download_fail_line3,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,fileName);
        n.icon=android.R.drawable.stat_sys_upload_done;
      }
 else {
        title=mContext.getString(R.string.notification_received,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.when=timeStamp;
    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);
    mNotificationMgr.notify(id,n);
  }
  cursor.close();
}