Program: 14402
Project: 14402
Buggy source:
private String uploadImage(MediaFile mediaFile){
  AppLog.d(T.POSTS,"String_Node_Str" + mediaFile);
  if (mediaFile.getFilePath() == null) {
    return null;
  }
  Uri imageUri=Uri.parse(mediaFile.getFilePath());
  File imageFile=null;
  String mimeType="String_Node_Str", path="String_Node_Str";
  if (imageUri.toString().contains("String_Node_Str")) {
    String[] projection=new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.MIME_TYPE};
    Cursor cur=mContext.getContentResolver().query(imageUri,projection,null,null,null);
    if (cur != null && cur.moveToFirst()) {
      int dataColumn=cur.getColumnIndex(Images.Media.DATA);
      int mimeTypeColumn=cur.getColumnIndex(Images.Media.MIME_TYPE);
      String thumbData=cur.getString(dataColumn);
      mimeType=cur.getString(mimeTypeColumn);
      imageFile=new File(thumbData);
      path=thumbData;
      mediaFile.setFilePath(imageFile.getPath());
    }
  }
 else {
    path=imageUri.toString().replace("String_Node_Str","String_Node_Str");
    imageFile=new File(path);
    mediaFile.setFilePath(path);
  }
  if (imageFile == null) {
    mErrorMessage=mContext.getString(R.string.file_not_found);
    return null;
  }
  if (TextUtils.isEmpty(mimeType)) {
    mimeType=MediaUtils.getMediaFileMimeType(imageFile);
  }
  String fileName=MediaUtils.getMediaFileName(imageFile,mimeType);
  String fileExtension=MimeTypeMap.getFileExtensionFromUrl(fileName).toLowerCase();
  int orientation=ImageUtils.getImageOrientation(mContext,path);
  String resizedPictureURL=null;
  boolean shouldUploadResizedVersion=false;
  if (!mimeType.equals("String_Node_Str") && !mBlog.getMaxImageWidth().equals("String_Node_Str")) {
    int pictureSettingWidth=mediaFile.getWidth();
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapFactory.decodeFile(path,options);
    int imageHeight=options.outHeight;
    int imageWidth=options.outWidth;
    int[] dimensions={imageWidth,imageHeight};
    if (dimensions[0] != 0 && dimensions[0] != pictureSettingWidth) {
      shouldUploadResizedVersion=true;
    }
  }
  boolean shouldAddImageWidthCSS=false;
  if (shouldUploadResizedVersion) {
    MediaFile resizedMediaFile=new MediaFile(mediaFile);
    byte[] bytes=ImageUtils.createThumbnailFromUri(mContext,imageUri,resizedMediaFile.getWidth(),fileExtension,orientation);
    if (bytes == null) {
      shouldUploadResizedVersion=false;
      shouldAddImageWidthCSS=true;
    }
 else {
      String tempFilePath;
      File resizedImageFile;
      try {
        resizedImageFile=File.createTempFile("String_Node_Str",fileExtension);
        FileOutputStream out=new FileOutputStream(resizedImageFile);
        out.write(bytes);
        out.close();
        tempFilePath=resizedImageFile.getPath();
      }
 catch (      IOException e) {
        AppLog.w(T.POSTS,"String_Node_Str");
        mErrorMessage=mContext.getString(R.string.error_media_upload);
        return null;
      }
      if (!TextUtils.isEmpty(tempFilePath)) {
        resizedMediaFile.setFilePath(tempFilePath);
        Map<String,Object> parameters=new HashMap<String,Object>();
        parameters.put("String_Node_Str",fileName);
        parameters.put("String_Node_Str",mimeType);
        parameters.put("String_Node_Str",resizedMediaFile);
        parameters.put("String_Node_Str",true);
        resizedPictureURL=uploadImageFile(parameters,resizedMediaFile,mBlog);
        if (resizedPictureURL == null) {
          AppLog.w(T.POSTS,"String_Node_Str");
          return null;
        }
 else         if (resizedImageFile.exists()) {
          resizedImageFile.delete();
        }
      }
 else {
        AppLog.w(T.POSTS,"String_Node_Str");
        mErrorMessage=mContext.getString(R.string.out_of_memory);
        return null;
      }
    }
  }
  String fullSizeUrl=null;
  if (!shouldUploadResizedVersion || mBlog.isFullSizeImage()) {
    Map<String,Object> parameters=new HashMap<String,Object>();
    parameters.put("String_Node_Str",fileName);
    parameters.put("String_Node_Str",mimeType);
    parameters.put("String_Node_Str",mediaFile);
    parameters.put("String_Node_Str",true);
    fullSizeUrl=uploadImageFile(parameters,mediaFile,mBlog);
    if (fullSizeUrl == null) {
      mErrorMessage=mContext.getString(R.string.error_media_upload);
      return null;
    }
  }
  return mediaFile.getImageHtmlForUrls(fullSizeUrl,resizedPictureURL,shouldAddImageWidthCSS);
}

Fixed version (ground truth):
private String uploadImage(MediaFile mediaFile){
  AppLog.d(T.POSTS,"String_Node_Str" + mediaFile.getFilePath());
  if (mediaFile.getFilePath() == null) {
    return null;
  }
  Uri imageUri=Uri.parse(mediaFile.getFilePath());
  File imageFile=null;
  String mimeType="String_Node_Str", path="String_Node_Str";
  if (imageUri.toString().contains("String_Node_Str")) {
    String[] projection=new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.MIME_TYPE};
    Cursor cur=mContext.getContentResolver().query(imageUri,projection,null,null,null);
    if (cur != null && cur.moveToFirst()) {
      int dataColumn=cur.getColumnIndex(Images.Media.DATA);
      int mimeTypeColumn=cur.getColumnIndex(Images.Media.MIME_TYPE);
      String thumbData=cur.getString(dataColumn);
      mimeType=cur.getString(mimeTypeColumn);
      imageFile=new File(thumbData);
      path=thumbData;
      mediaFile.setFilePath(imageFile.getPath());
    }
  }
 else {
    path=imageUri.toString().replace("String_Node_Str","String_Node_Str");
    imageFile=new File(path);
    mediaFile.setFilePath(path);
  }
  if (imageFile == null) {
    mErrorMessage=mContext.getString(R.string.file_not_found);
    return null;
  }
  if (TextUtils.isEmpty(mimeType)) {
    mimeType=MediaUtils.getMediaFileMimeType(imageFile);
  }
  String fileName=MediaUtils.getMediaFileName(imageFile,mimeType);
  String fileExtension=MimeTypeMap.getFileExtensionFromUrl(fileName).toLowerCase();
  int orientation=ImageUtils.getImageOrientation(mContext,path);
  String resizedPictureURL=null;
  boolean shouldUploadResizedVersion=false;
  if (!mimeType.equals("String_Node_Str") && !mBlog.getMaxImageWidth().equals("String_Node_Str")) {
    int pictureSettingWidth=mediaFile.getWidth();
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    BitmapFactory.decodeFile(path,options);
    int imageHeight=options.outHeight;
    int imageWidth=options.outWidth;
    int[] dimensions={imageWidth,imageHeight};
    if (dimensions[0] != 0 && dimensions[0] != pictureSettingWidth) {
      shouldUploadResizedVersion=true;
    }
  }
  boolean shouldAddImageWidthCSS=false;
  if (shouldUploadResizedVersion) {
    MediaFile resizedMediaFile=new MediaFile(mediaFile);
    byte[] bytes=ImageUtils.createThumbnailFromUri(mContext,imageUri,resizedMediaFile.getWidth(),fileExtension,orientation);
    if (bytes == null) {
      shouldUploadResizedVersion=false;
      shouldAddImageWidthCSS=true;
    }
 else {
      String tempFilePath;
      File resizedImageFile;
      try {
        resizedImageFile=File.createTempFile("String_Node_Str",fileExtension);
        FileOutputStream out=new FileOutputStream(resizedImageFile);
        out.write(bytes);
        out.close();
        tempFilePath=resizedImageFile.getPath();
      }
 catch (      IOException e) {
        AppLog.w(T.POSTS,"String_Node_Str");
        mErrorMessage=mContext.getString(R.string.error_media_upload);
        return null;
      }
      if (!TextUtils.isEmpty(tempFilePath)) {
        resizedMediaFile.setFilePath(tempFilePath);
        Map<String,Object> parameters=new HashMap<String,Object>();
        parameters.put("String_Node_Str",fileName);
        parameters.put("String_Node_Str",mimeType);
        parameters.put("String_Node_Str",resizedMediaFile);
        parameters.put("String_Node_Str",true);
        resizedPictureURL=uploadImageFile(parameters,resizedMediaFile,mBlog);
        if (resizedPictureURL == null) {
          AppLog.w(T.POSTS,"String_Node_Str");
          return null;
        }
 else         if (resizedImageFile.exists()) {
          resizedImageFile.delete();
        }
      }
 else {
        AppLog.w(T.POSTS,"String_Node_Str");
        mErrorMessage=mContext.getString(R.string.out_of_memory);
        return null;
      }
    }
  }
  String fullSizeUrl=null;
  if (!shouldUploadResizedVersion || mBlog.isFullSizeImage()) {
    Map<String,Object> parameters=new HashMap<String,Object>();
    parameters.put("String_Node_Str",fileName);
    parameters.put("String_Node_Str",mimeType);
    parameters.put("String_Node_Str",mediaFile);
    parameters.put("String_Node_Str",true);
    fullSizeUrl=uploadImageFile(parameters,mediaFile,mBlog);
    if (fullSizeUrl == null) {
      mErrorMessage=mContext.getString(R.string.error_media_upload);
      return null;
    }
  }
  return mediaFile.getImageHtmlForUrls(fullSizeUrl,resizedPictureURL,shouldAddImageWidthCSS);
}