Program: 2477
Project: 2477
Buggy source:
@Override protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params){
  if (params.length != 1)   return null;
  if (isCancelled()) {
    params[0].clearImage();
    Log.d(TAG,"String_Node_Str");
    return null;
  }
  Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
  Context context=params[0].context;
  Bitmap image=params[0].image;
  Resources r=context.getResources();
  try {
    mScreenshotDir.mkdirs();
    ContentValues values=new ContentValues();
    ContentResolver resolver=context.getContentResolver();
    values.put(MediaStore.Images.ImageColumns.DATA,mImageFilePath);
    values.put(MediaStore.Images.ImageColumns.TITLE,mImageFileName);
    values.put(MediaStore.Images.ImageColumns.DISPLAY_NAME,mImageFileName);
    values.put(MediaStore.Images.ImageColumns.DATE_TAKEN,mImageTime);
    values.put(MediaStore.Images.ImageColumns.DATE_ADDED,mImageTime);
    values.put(MediaStore.Images.ImageColumns.DATE_MODIFIED,mImageTime);
    values.put(MediaStore.Images.ImageColumns.MIME_TYPE,"String_Node_Str");
    values.put(MediaStore.Images.ImageColumns.WIDTH,mImageWidth);
    values.put(MediaStore.Images.ImageColumns.HEIGHT,mImageHeight);
    Uri uri=resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);
    String subjectDate=new SimpleDateFormat("String_Node_Str").format(new Date(mImageTime));
    String subject=String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE,subjectDate);
    Intent sharingIntent=new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("String_Node_Str");
    sharingIntent.putExtra(Intent.EXTRA_STREAM,uri);
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT,subject);
    Intent chooserIntent=Intent.createChooser(sharingIntent,null);
    chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    mNotificationBuilder.addAction(R.drawable.ic_menu_share,r.getString(com.android.internal.R.string.share),PendingIntent.getActivity(context,0,chooserIntent,PendingIntent.FLAG_CANCEL_CURRENT));
    OutputStream out=resolver.openOutputStream(uri);
    image.compress(Bitmap.CompressFormat.PNG,100,out);
    out.flush();
    out.close();
    values.clear();
    values.put(MediaStore.Images.ImageColumns.SIZE,new File(mImageFilePath).length());
    resolver.update(uri,values,null,null);
    params[0].imageUri=uri;
    params[0].image=null;
    params[0].result=0;
  }
 catch (  Exception e) {
    params[0].clearImage();
    params[0].result=1;
    Log.d(TAG,"String_Node_Str");
  }
  if (image != null) {
    image.recycle();
  }
  Log.d(TAG,"String_Node_Str");
  return params[0];
}

Fixed version (ground truth):
@Override protected SaveImageInBackgroundData doInBackground(SaveImageInBackgroundData... params){
  if (params.length != 1)   return null;
  if (isCancelled()) {
    params[0].clearImage();
    params[0].clearContext();
    return null;
  }
  Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
  Context context=params[0].context;
  Bitmap image=params[0].image;
  Resources r=context.getResources();
  try {
    mScreenshotDir.mkdirs();
    ContentValues values=new ContentValues();
    ContentResolver resolver=context.getContentResolver();
    values.put(MediaStore.Images.ImageColumns.DATA,mImageFilePath);
    values.put(MediaStore.Images.ImageColumns.TITLE,mImageFileName);
    values.put(MediaStore.Images.ImageColumns.DISPLAY_NAME,mImageFileName);
    values.put(MediaStore.Images.ImageColumns.DATE_TAKEN,mImageTime);
    values.put(MediaStore.Images.ImageColumns.DATE_ADDED,mImageTime);
    values.put(MediaStore.Images.ImageColumns.DATE_MODIFIED,mImageTime);
    values.put(MediaStore.Images.ImageColumns.MIME_TYPE,"String_Node_Str");
    values.put(MediaStore.Images.ImageColumns.WIDTH,mImageWidth);
    values.put(MediaStore.Images.ImageColumns.HEIGHT,mImageHeight);
    Uri uri=resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,values);
    String subjectDate=new SimpleDateFormat("String_Node_Str").format(new Date(mImageTime));
    String subject=String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE,subjectDate);
    Intent sharingIntent=new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("String_Node_Str");
    sharingIntent.putExtra(Intent.EXTRA_STREAM,uri);
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT,subject);
    Intent chooserIntent=Intent.createChooser(sharingIntent,null);
    chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    mNotificationBuilder.addAction(R.drawable.ic_menu_share,r.getString(com.android.internal.R.string.share),PendingIntent.getActivity(context,0,chooserIntent,PendingIntent.FLAG_CANCEL_CURRENT));
    OutputStream out=resolver.openOutputStream(uri);
    image.compress(Bitmap.CompressFormat.PNG,100,out);
    out.flush();
    out.close();
    values.clear();
    values.put(MediaStore.Images.ImageColumns.SIZE,new File(mImageFilePath).length());
    resolver.update(uri,values,null,null);
    params[0].imageUri=uri;
    params[0].image=null;
    params[0].result=0;
  }
 catch (  Exception e) {
    params[0].clearImage();
    params[0].result=1;
  }
  if (image != null) {
    image.recycle();
  }
  return params[0];
}