Program: 170184
Project: 170184
Buggy source:
/** 
 * The real guts of parseNetworkResponse. Broken out for readability.
 */
private Bitmap doParse(NetworkResponse response){
  byte[] data=response.data;
  BitmapFactory.Options decodeOptions=new BitmapFactory.Options();
  Bitmap bitmap=null;
  if (mMaxWidth == 0 && mMaxHeight == 0) {
    decodeOptions.inPreferredConfig=mDecodeConfig;
    bitmap=BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
  }
 else {
    decodeOptions.inJustDecodeBounds=true;
    BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
    int actualWidth=decodeOptions.outWidth;
    int actualHeight=decodeOptions.outHeight;
    int desiredWidth=getResizedDimension(mMaxWidth,mMaxHeight,actualWidth,actualHeight);
    int desiredHeight=getResizedDimension(mMaxHeight,mMaxWidth,actualHeight,actualWidth);
    decodeOptions.inJustDecodeBounds=false;
    decodeOptions.inSampleSize=findBestSampleSize(actualWidth,actualHeight,desiredWidth,desiredHeight);
    Bitmap tempBitmap=BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
    if (tempBitmap != null && (tempBitmap.getWidth() > desiredWidth || tempBitmap.getHeight() > desiredHeight)) {
      bitmap=Bitmap.createScaledBitmap(tempBitmap,desiredWidth,desiredHeight,true);
      tempBitmap.recycle();
    }
 else {
      bitmap=tempBitmap;
    }
  }
  return bitmap;
}

Fixed version (ground truth):
/** 
 * The real guts of parseNetworkResponse. Broken out for readability.
 */
private Bitmap doParse(NetworkResponse response){
  byte[] data=response.data;
  BitmapFactory.Options decodeOptions=new BitmapFactory.Options();
  Bitmap bitmap=null;
  if (mMaxWidth == 0 && mMaxHeight == 0) {
    decodeOptions.inPreferredConfig=mDecodeConfig;
    bitmap=BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
  }
 else {
    decodeOptions.inJustDecodeBounds=true;
    BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
    int actualWidth=decodeOptions.outWidth;
    int actualHeight=decodeOptions.outHeight;
    int desiredWidth=getResizedDimension(mMaxWidth,mMaxHeight,actualWidth,actualHeight);
    int desiredHeight=getResizedDimension(mMaxHeight,mMaxWidth,actualHeight,actualWidth);
    decodeOptions.inJustDecodeBounds=false;
    decodeOptions.inPreferQualityOverSpeed=true;
    decodeOptions.inSampleSize=findBestSampleSize(actualWidth,actualHeight,desiredWidth,desiredHeight);
    Bitmap tempBitmap=BitmapFactory.decodeByteArray(data,0,data.length,decodeOptions);
    Bitmap tempBitmap2;
    if (tempBitmap != null && (tempBitmap.getWidth() > desiredWidth || tempBitmap.getHeight() > desiredHeight)) {
      tempBitmap2=Bitmap.createScaledBitmap(tempBitmap,desiredWidth,desiredHeight,true);
      tempBitmap.recycle();
    }
 else     if (tempBitmap == null) {
      return null;
    }
 else {
      tempBitmap2=tempBitmap;
    }
    int w=tempBitmap2.getWidth();
    int h=tempBitmap2.getHeight();
    if (w > h) {
      bitmap=Bitmap.createBitmap(tempBitmap2,w / 2 - h / 2,0,h,h);
      tempBitmap2.recycle();
    }
 else     if (h > w) {
      bitmap=Bitmap.createBitmap(tempBitmap2,0,0,w,w);
      tempBitmap2.recycle();
    }
 else {
      bitmap=tempBitmap2;
    }
  }
  return bitmap;
}