Program: 15181
Project: 15181
Buggy source:
public String uploadImage(MediaFile mf){
  String content="String_Node_Str";
  String finalThumbnailUrl=null;
  String finalImageUrl=null;
  if (mf.getFileName() != null) {
    XMLRPCClient client=new XMLRPCClient(post.blog.getUrl(),post.blog.getHttpuser(),post.blog.getHttppassword());
    String curImagePath="String_Node_Str";
    curImagePath=mf.getFileName();
    boolean video=false;
    if (curImagePath.contains("String_Node_Str")) {
      video=true;
    }
    if (video) {
      Uri videoUri=Uri.parse(curImagePath);
      File fVideo=null;
      String mimeType="String_Node_Str", xRes="String_Node_Str", yRes="String_Node_Str";
      if (videoUri.toString().contains("String_Node_Str")) {
        String[] projection;
        Uri imgPath;
        projection=new String[]{Video.Media._ID,Video.Media.DATA,Video.Media.MIME_TYPE,Video.Media.RESOLUTION};
        imgPath=videoUri;
        Cursor cur=context.getContentResolver().query(imgPath,projection,null,null,null);
        String thumbData="String_Node_Str";
        if (cur.moveToFirst()) {
          int mimeTypeColumn, resolutionColumn, dataColumn;
          dataColumn=cur.getColumnIndex(Video.Media.DATA);
          mimeTypeColumn=cur.getColumnIndex(Video.Media.MIME_TYPE);
          resolutionColumn=cur.getColumnIndex(Video.Media.RESOLUTION);
          mf=new MediaFile();
          thumbData=cur.getString(dataColumn);
          mimeType=cur.getString(mimeTypeColumn);
          fVideo=new File(thumbData);
          mf.setFilePath(fVideo.getPath());
          String resolution=cur.getString(resolutionColumn);
          if (resolution != null) {
            String[] resx=resolution.split("String_Node_Str");
            xRes=resx[0];
            yRes=resx[1];
          }
 else {
            if (!post.blog.getMaxImageWidth().equals("String_Node_Str")) {
              xRes=post.blog.getMaxImageWidth();
              yRes=String.valueOf(Math.round(Integer.valueOf(post.blog.getMaxImageWidth()) * 0.75));
            }
 else {
              xRes="String_Node_Str";
              yRes="String_Node_Str";
            }
          }
        }
      }
 else {
        fVideo=new File(videoUri.toString().replace("String_Node_Str","String_Node_Str"));
      }
      String imageTitle=fVideo.getName();
      HashMap<String,Object> m=new HashMap<String,Object>();
      m.put("String_Node_Str",imageTitle);
      m.put("String_Node_Str",mimeType);
      m.put("String_Node_Str",mf);
      m.put("String_Node_Str",true);
      Object[] params={1,post.blog.getUsername(),post.blog.getPassword(),m};
      Object result=null;
      try {
        result=(Object)client.call("String_Node_Str",params);
      }
 catch (      XMLRPCException e) {
        String mediaErrorMsg=e.getLocalizedMessage();
        if (video) {
          if (mediaErrorMsg.contains("String_Node_Str")) {
            mediaErrorMsg=context.getResources().getString(R.string.vp_upgrade);
          }
        }
        return null;
      }
      HashMap<?,?> contentHash=new HashMap<Object,Object>();
      contentHash=(HashMap<?,?>)result;
      String resultURL=contentHash.get("String_Node_Str").toString();
      if (contentHash.containsKey("String_Node_Str")) {
        resultURL=contentHash.get("String_Node_Str").toString() + "String_Node_Str";
      }
 else {
        resultURL=String.format("String_Node_Str",xRes,yRes,resultURL,mimeType,resultURL);
      }
      content=content + resultURL;
    }
 else {
      for (int i=0; i < 2; i++) {
        curImagePath=mf.getFileName();
        if (i == 0 || post.blog.isFullSizeImage()) {
          Uri imageUri=Uri.parse(curImagePath);
          File jpeg=null;
          String mimeType="String_Node_Str", orientation="String_Node_Str", path="String_Node_Str";
          if (imageUri.toString().contains("String_Node_Str")) {
            String[] projection;
            Uri imgPath;
            projection=new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.MIME_TYPE,Images.Media.ORIENTATION};
            imgPath=imageUri;
            Cursor cur=context.getContentResolver().query(imgPath,projection,null,null,null);
            String thumbData="String_Node_Str";
            if (cur.moveToFirst()) {
              int dataColumn, mimeTypeColumn, orientationColumn;
              dataColumn=cur.getColumnIndex(Images.Media.DATA);
              mimeTypeColumn=cur.getColumnIndex(Images.Media.MIME_TYPE);
              orientationColumn=cur.getColumnIndex(Images.Media.ORIENTATION);
              orientation=cur.getString(orientationColumn);
              thumbData=cur.getString(dataColumn);
              mimeType=cur.getString(mimeTypeColumn);
              jpeg=new File(thumbData);
              path=thumbData;
              mf.setFilePath(jpeg.getPath());
            }
          }
 else {
            path=imageUri.toString().replace("String_Node_Str","String_Node_Str");
            jpeg=new File(path);
            mf.setFilePath(path);
          }
          if (jpeg == null) {
            break;
          }
          ImageHelper ih=new ImageHelper();
          orientation=ih.getExifOrientation(path,orientation);
          String imageTitle=jpeg.getName();
          byte[] finalBytes=null;
          if (i == 0) {
            byte[] bytes=new byte[(int)jpeg.length()];
            DataInputStream in=null;
            try {
              in=new DataInputStream(new FileInputStream(jpeg));
            }
 catch (            FileNotFoundException e) {
              e.printStackTrace();
            }
            try {
              in.readFully(bytes);
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
            try {
              in.close();
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
            ImageHelper ih2=new ImageHelper();
            finalBytes=ih2.createThumbnail(bytes,String.valueOf(mf.getWidth()),orientation,false);
          }
          if (finalBytes == null) {
            error=context.getResources().getText(R.string.media_error).toString();
            return null;
          }
          Map<String,Object> m=new HashMap<String,Object>();
          m.put("String_Node_Str",imageTitle);
          m.put("String_Node_Str",mimeType);
          if (i == 0) {
            m.put("String_Node_Str",finalBytes);
          }
 else {
            m.put("String_Node_Str",mf);
          }
          m.put("String_Node_Str",true);
          Object[] params={1,post.blog.getUsername(),post.blog.getPassword(),m};
          Object result=null;
          try {
            result=(Object)client.call("String_Node_Str",params);
          }
 catch (          XMLRPCException e) {
            error=e.getMessage();
            return null;
          }
          HashMap<?,?> contentHash=new HashMap<Object,Object>();
          contentHash=(HashMap<?,?>)result;
          String resultURL=contentHash.get("String_Node_Str").toString();
          if (i == 0) {
            finalThumbnailUrl=resultURL;
          }
 else {
            if (post.blog.isFullSizeImage()) {
              finalImageUrl=resultURL;
            }
 else {
              finalImageUrl="String_Node_Str";
            }
          }
          String alignment="String_Node_Str";
switch (mf.getHorizontalAlignment()) {
case 0:
            alignment="String_Node_Str";
          break;
case 1:
        alignment="String_Node_Str";
      break;
case 2:
    alignment="String_Node_Str";
  break;
case 3:
alignment="String_Node_Str";
break;
}
String alignmentCSS="String_Node_Str" + alignment + "String_Node_Str";
if (resultURL != null) {
if (i != 0 && post.blog.isFullSizeImage()) {
content=content + "String_Node_Str" + finalImageUrl+ "String_Node_Str"+ mf.getTitle()+ "String_Node_Str"+ alignmentCSS+ "String_Node_Str"+ finalThumbnailUrl+ "String_Node_Str";
}
 else {
if (i == 0 && post.blog.isFullSizeImage() == false) {
content=content + "String_Node_Str" + mf.getTitle()+ "String_Node_Str"+ alignmentCSS+ "String_Node_Str"+ finalThumbnailUrl+ "String_Node_Str";
}
}
if (!mf.getCaption().equals("String_Node_Str")) {
content=String.format("String_Node_Str",alignment,mf.getWidth(),EscapeUtils.escapeHtml(mf.getCaption()),content);
}
}
}
}
}
}
return content;
}

Fixed version (ground truth):
public String uploadImage(MediaFile mf){
  String content="String_Node_Str";
  String finalThumbnailUrl=null;
  String finalImageUrl=null;
  if (mf.getFileName() != null) {
    XMLRPCClient client=new XMLRPCClient(post.blog.getUrl(),post.blog.getHttpuser(),post.blog.getHttppassword());
    String curImagePath="String_Node_Str";
    curImagePath=mf.getFileName();
    boolean video=false;
    if (curImagePath.contains("String_Node_Str")) {
      video=true;
    }
    if (video) {
      Uri videoUri=Uri.parse(curImagePath);
      File fVideo=null;
      String mimeType="String_Node_Str", xRes="String_Node_Str", yRes="String_Node_Str";
      if (videoUri.toString().contains("String_Node_Str")) {
        String[] projection;
        Uri imgPath;
        projection=new String[]{Video.Media._ID,Video.Media.DATA,Video.Media.MIME_TYPE,Video.Media.RESOLUTION};
        imgPath=videoUri;
        Cursor cur=context.getContentResolver().query(imgPath,projection,null,null,null);
        String thumbData="String_Node_Str";
        if (cur.moveToFirst()) {
          int mimeTypeColumn, resolutionColumn, dataColumn;
          dataColumn=cur.getColumnIndex(Video.Media.DATA);
          mimeTypeColumn=cur.getColumnIndex(Video.Media.MIME_TYPE);
          resolutionColumn=cur.getColumnIndex(Video.Media.RESOLUTION);
          mf=new MediaFile();
          thumbData=cur.getString(dataColumn);
          mimeType=cur.getString(mimeTypeColumn);
          fVideo=new File(thumbData);
          mf.setFilePath(fVideo.getPath());
          String resolution=cur.getString(resolutionColumn);
          if (resolution != null) {
            String[] resx=resolution.split("String_Node_Str");
            xRes=resx[0];
            yRes=resx[1];
          }
 else {
            if (!post.blog.getMaxImageWidth().equals("String_Node_Str")) {
              xRes=post.blog.getMaxImageWidth();
              yRes=String.valueOf(Math.round(Integer.valueOf(post.blog.getMaxImageWidth()) * 0.75));
            }
 else {
              xRes="String_Node_Str";
              yRes="String_Node_Str";
            }
          }
        }
      }
 else {
        fVideo=new File(videoUri.toString().replace("String_Node_Str","String_Node_Str"));
      }
      String imageTitle=fVideo.getName();
      HashMap<String,Object> m=new HashMap<String,Object>();
      m.put("String_Node_Str",imageTitle);
      m.put("String_Node_Str",mimeType);
      m.put("String_Node_Str",mf);
      m.put("String_Node_Str",true);
      Object[] params={1,post.blog.getUsername(),post.blog.getPassword(),m};
      Object result=null;
      try {
        result=(Object)client.call("String_Node_Str",params);
      }
 catch (      XMLRPCException e) {
        String mediaErrorMsg=e.getLocalizedMessage();
        if (video) {
          if (mediaErrorMsg.contains("String_Node_Str")) {
            mediaErrorMsg=context.getResources().getString(R.string.vp_upgrade);
          }
        }
        return null;
      }
      HashMap<?,?> contentHash=new HashMap<Object,Object>();
      contentHash=(HashMap<?,?>)result;
      String resultURL=contentHash.get("String_Node_Str").toString();
      if (contentHash.containsKey("String_Node_Str")) {
        resultURL=contentHash.get("String_Node_Str").toString() + "String_Node_Str";
      }
 else {
        resultURL=String.format("String_Node_Str",xRes,yRes,resultURL,mimeType,resultURL);
      }
      content=content + resultURL;
    }
 else {
      for (int i=0; i < 2; i++) {
        curImagePath=mf.getFileName();
        if (i == 0 || post.blog.isFullSizeImage()) {
          Uri imageUri=Uri.parse(curImagePath);
          File jpeg=null;
          String mimeType="String_Node_Str", orientation="String_Node_Str", path="String_Node_Str";
          if (imageUri.toString().contains("String_Node_Str")) {
            String[] projection;
            Uri imgPath;
            projection=new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.MIME_TYPE,Images.Media.ORIENTATION};
            imgPath=imageUri;
            Cursor cur=context.getContentResolver().query(imgPath,projection,null,null,null);
            String thumbData="String_Node_Str";
            if (cur.moveToFirst()) {
              int dataColumn, mimeTypeColumn, orientationColumn;
              dataColumn=cur.getColumnIndex(Images.Media.DATA);
              mimeTypeColumn=cur.getColumnIndex(Images.Media.MIME_TYPE);
              orientationColumn=cur.getColumnIndex(Images.Media.ORIENTATION);
              orientation=cur.getString(orientationColumn);
              thumbData=cur.getString(dataColumn);
              mimeType=cur.getString(mimeTypeColumn);
              jpeg=new File(thumbData);
              path=thumbData;
              mf.setFilePath(jpeg.getPath());
            }
          }
 else {
            path=imageUri.toString().replace("String_Node_Str","String_Node_Str");
            jpeg=new File(path);
            mf.setFilePath(path);
          }
          if (jpeg == null) {
            break;
          }
          ImageHelper ih=new ImageHelper();
          orientation=ih.getExifOrientation(path,orientation);
          String imageTitle=jpeg.getName();
          byte[] finalBytes=null;
          if (i == 0) {
            byte[] bytes=new byte[(int)jpeg.length()];
            DataInputStream in=null;
            try {
              in=new DataInputStream(new FileInputStream(jpeg));
            }
 catch (            FileNotFoundException e) {
              e.printStackTrace();
            }
            try {
              in.readFully(bytes);
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
            try {
              in.close();
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
            ImageHelper ih2=new ImageHelper();
            finalBytes=ih2.createThumbnail(bytes,String.valueOf(mf.getWidth()),orientation,false);
            if (finalBytes == null) {
              error=context.getResources().getText(R.string.media_error).toString();
              return null;
            }
          }
          Map<String,Object> m=new HashMap<String,Object>();
          m.put("String_Node_Str",imageTitle);
          m.put("String_Node_Str",mimeType);
          if (i == 0) {
            m.put("String_Node_Str",finalBytes);
          }
 else {
            m.put("String_Node_Str",mf);
          }
          m.put("String_Node_Str",true);
          Object[] params={1,post.blog.getUsername(),post.blog.getPassword(),m};
          Object result=null;
          try {
            result=(Object)client.call("String_Node_Str",params);
          }
 catch (          XMLRPCException e) {
            error=e.getMessage();
            return null;
          }
          HashMap<?,?> contentHash=new HashMap<Object,Object>();
          contentHash=(HashMap<?,?>)result;
          String resultURL=contentHash.get("String_Node_Str").toString();
          if (i == 0) {
            finalThumbnailUrl=resultURL;
          }
 else {
            if (post.blog.isFullSizeImage()) {
              finalImageUrl=resultURL;
            }
 else {
              finalImageUrl="String_Node_Str";
            }
          }
          String alignment="String_Node_Str";
switch (mf.getHorizontalAlignment()) {
case 0:
            alignment="String_Node_Str";
          break;
case 1:
        alignment="String_Node_Str";
      break;
case 2:
    alignment="String_Node_Str";
  break;
case 3:
alignment="String_Node_Str";
break;
}
String alignmentCSS="String_Node_Str" + alignment + "String_Node_Str";
if (resultURL != null) {
if (i != 0 && post.blog.isFullSizeImage()) {
content=content + "String_Node_Str" + finalImageUrl+ "String_Node_Str"+ mf.getTitle()+ "String_Node_Str"+ alignmentCSS+ "String_Node_Str"+ finalThumbnailUrl+ "String_Node_Str";
}
 else {
if (i == 0 && post.blog.isFullSizeImage() == false) {
content=content + "String_Node_Str" + mf.getTitle()+ "String_Node_Str"+ alignmentCSS+ "String_Node_Str"+ finalThumbnailUrl+ "String_Node_Str";
}
}
if (!mf.getCaption().equals("String_Node_Str")) {
content=String.format("String_Node_Str",alignment,mf.getWidth(),EscapeUtils.escapeHtml(mf.getCaption()),content);
}
}
}
}
}
}
return content;
}