Program: 190844
Project: 190844
Buggy source:
static Bitmap transformResult(Request data,Bitmap result,int exifRotation){
  int inWidth=result.getWidth();
  int inHeight=result.getHeight();
  int drawX=0;
  int drawY=0;
  int drawWidth=inWidth;
  int drawHeight=inHeight;
  Matrix matrix=new Matrix();
  if (data.needsMatrixTransform()) {
    int targetWidth=data.targetWidth;
    int targetHeight=data.targetHeight;
    float targetRotation=data.rotationDegrees;
    if (targetRotation != 0) {
      if (data.hasRotationPivot) {
        matrix.setRotate(targetRotation,data.rotationPivotX,data.rotationPivotY);
      }
 else {
        matrix.setRotate(targetRotation);
      }
    }
    if (data.centerCrop) {
      float widthRatio=targetWidth / (float)inWidth;
      float heightRatio=targetHeight / (float)inHeight;
      float scale;
      if (widthRatio > heightRatio) {
        scale=widthRatio;
        int newSize=(int)Math.ceil(inHeight * (heightRatio / widthRatio));
        drawY=(inHeight - newSize) / 2;
        drawHeight=newSize;
      }
 else {
        scale=heightRatio;
        int newSize=(int)Math.ceil(inWidth * (widthRatio / heightRatio));
        drawX=(inWidth - newSize) / 2;
        drawWidth=newSize;
      }
      matrix.preScale(scale,scale);
    }
 else     if (data.centerInside) {
      float widthRatio=targetWidth / (float)inWidth;
      float heightRatio=targetHeight / (float)inHeight;
      float scale=widthRatio < heightRatio ? widthRatio : heightRatio;
      matrix.preScale(scale,scale);
    }
 else     if (targetWidth != 0 && targetHeight != 0 && (targetWidth != inWidth || targetHeight != inHeight)) {
      float sx=targetWidth / (float)inWidth;
      float sy=targetHeight / (float)inHeight;
      matrix.preScale(sx,sy);
    }
  }
  if (exifRotation != 0) {
    matrix.preRotate(exifRotation);
  }
  Bitmap newResult=Bitmap.createBitmap(result,drawX,drawY,drawWidth,drawHeight,matrix,false);
  if (newResult != result) {
    result.recycle();
    result=newResult;
  }
  return result;
}

Fixed version (ground truth):
static Bitmap transformResult(Request data,Bitmap result,int exifRotation){
  int inWidth=result.getWidth();
  int inHeight=result.getHeight();
  int drawX=0;
  int drawY=0;
  int drawWidth=inWidth;
  int drawHeight=inHeight;
  Matrix matrix=new Matrix();
  if (data.needsMatrixTransform()) {
    int targetWidth=data.targetWidth;
    int targetHeight=data.targetHeight;
    float targetRotation=data.rotationDegrees;
    if (targetRotation != 0) {
      if (data.hasRotationPivot) {
        matrix.setRotate(targetRotation,data.rotationPivotX,data.rotationPivotY);
      }
 else {
        matrix.setRotate(targetRotation);
      }
    }
    if (data.centerCrop) {
      float widthRatio=targetWidth / (float)inWidth;
      float heightRatio=targetHeight / (float)inHeight;
      float scale;
      if (widthRatio > heightRatio) {
        scale=widthRatio;
        int newSize=(int)Math.ceil(inHeight * (heightRatio / widthRatio));
        drawY=(inHeight - newSize) / 2;
        drawHeight=newSize;
      }
 else {
        scale=heightRatio;
        int newSize=(int)Math.ceil(inWidth * (widthRatio / heightRatio));
        drawX=(inWidth - newSize) / 2;
        drawWidth=newSize;
      }
      matrix.preScale(scale,scale);
    }
 else     if (data.centerInside) {
      float widthRatio=targetWidth / (float)inWidth;
      float heightRatio=targetHeight / (float)inHeight;
      float scale=widthRatio < heightRatio ? widthRatio : heightRatio;
      matrix.preScale(scale,scale);
    }
 else     if (targetWidth != 0 && targetHeight != 0 && (targetWidth != inWidth || targetHeight != inHeight)) {
      float sx=targetWidth / (float)inWidth;
      float sy=targetHeight / (float)inHeight;
      matrix.preScale(sx,sy);
    }
  }
  if (exifRotation != 0) {
    matrix.preRotate(exifRotation);
  }
  Bitmap newResult=Bitmap.createBitmap(result,drawX,drawY,drawWidth,drawHeight,matrix,true);
  if (newResult != result) {
    result.recycle();
    result=newResult;
  }
  return result;
}