Program: 185124
Project: 185124
Buggy source:
/** 
 * @param wmlPackage
 * @param imageDirPath - images won't be saved if this is not set
 * @param pictureData
 * @param picSize
 * @param picLink
 * @param linkData
 * @return
 */
public static WordXmlPicture createWordXmlPicture(WordprocessingMLPackage wmlPackage,String imageDirPath,NodeIterator pictureData,NodeIterator picSize,NodeIterator picLink,NodeIterator linkData){
  WordXmlPicture picture=new WordXmlPicture();
  picture.readStandardAttributes(pictureData.nextNode());
  Node picSizeNode=picSize.nextNode();
  if (picSizeNode != null) {
    picture.readSizeAttributes(picSizeNode);
  }
  Node picLinkNode=picLink.nextNode();
  if (picLinkNode != null) {
    String linkRelId=ConvertUtils.getAttributeValueNS(picLinkNode,"String_Node_Str","String_Node_Str");
    if (linkRelId != null && !linkRelId.equals("String_Node_Str")) {
      Relationship rel=wmlPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(linkRelId);
      if (rel.getTargetMode() == null || rel.getTargetMode().equals("String_Node_Str")) {
        picture.setHlinkReference("String_Node_Str");
      }
 else {
        picture.setHlinkReference(rel.getTarget());
      }
    }
    picture.readLinkAttributes(picLinkNode);
  }
  Node linkDataNode=linkData.nextNode();
  if (linkDataNode == null) {
    log.warn("String_Node_Str");
  }
 else {
    String imgRelId=ConvertUtils.getAttributeValueNS(linkDataNode,"String_Node_Str","String_Node_Str");
    if (imgRelId != null && !imgRelId.equals("String_Node_Str")) {
      Relationship rel=wmlPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(imgRelId);
      if (rel.getTargetMode() == null || rel.getTargetMode().equals("String_Node_Str")) {
        Part part=wmlPackage.getMainDocumentPart().getRelationshipsPart().getPart(rel);
        try {
          if (imageDirPath.equals("String_Node_Str")) {
            java.nio.ByteBuffer bb=((BinaryPart)part).getBuffer();
            bb.clear();
            byte[] bytes=new byte[bb.capacity()];
            bb.get(bytes,0,bytes.length);
            byte[] encoded=Base64.encodeBase64(bytes,true);
            picture.setSrc("String_Node_Str" + part.getContentType() + "String_Node_Str"+ (new String(encoded,"String_Node_Str")));
          }
 else {
            FileObject folder=getFileSystemManager().resolveFile(imageDirPath);
            if (!folder.exists()) {
              folder.createFolder();
            }
            String partname=part.getPartName().toString();
            String filename=partname.substring(partname.lastIndexOf("String_Node_Str") + 1);
            log.debug("String_Node_Str" + filename);
            FileObject fo=folder.resolveFile(filename);
            if (fo.exists()) {
              log.warn("String_Node_Str");
            }
 else {
              fo.createFile();
            }
            OutputStream out=fo.getContent().getOutputStream();
            java.nio.ByteBuffer bb=((BinaryPart)part).getBuffer();
            bb.clear();
            byte[] bytes=new byte[bb.capacity()];
            bb.get(bytes,0,bytes.length);
            out.write(bytes);
            String src=fixImgSrcURL(fo);
            picture.setSrc(src);
            log.info("String_Node_Str" + src);
          }
        }
 catch (        Exception e) {
          log.error(e);
        }
      }
 else {
        picture.setSrc(rel.getTarget());
      }
    }
  }
  return picture;
}

Fixed version (ground truth):
/** 
 * @param wmlPackage
 * @param imageDirPath - images won't be saved if this is not set
 * @param pictureData
 * @param picSize
 * @param picLink
 * @param linkData
 * @return
 */
public static WordXmlPicture createWordXmlPicture(WordprocessingMLPackage wmlPackage,String imageDirPath,NodeIterator pictureData,NodeIterator picSize,NodeIterator picLink,NodeIterator linkData){
  WordXmlPicture picture=new WordXmlPicture();
  picture.readStandardAttributes(pictureData.nextNode());
  Node picSizeNode=picSize.nextNode();
  if (picSizeNode != null) {
    picture.readSizeAttributes(picSizeNode);
  }
  Node picLinkNode=picLink.nextNode();
  if (picLinkNode != null) {
    String linkRelId=ConvertUtils.getAttributeValueNS(picLinkNode,"String_Node_Str","String_Node_Str");
    if (linkRelId != null && !linkRelId.equals("String_Node_Str")) {
      Relationship rel=wmlPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(linkRelId);
      if (rel.getTargetMode() == null || rel.getTargetMode().equals("String_Node_Str")) {
        picture.setHlinkReference("String_Node_Str");
      }
 else {
        picture.setHlinkReference(rel.getTarget());
      }
    }
    picture.readLinkAttributes(picLinkNode);
  }
  Node linkDataNode=linkData.nextNode();
  if (linkDataNode == null) {
    log.warn("String_Node_Str");
  }
 else {
    String imgRelId=ConvertUtils.getAttributeValueNS(linkDataNode,"String_Node_Str","String_Node_Str");
    if (imgRelId != null && !imgRelId.equals("String_Node_Str")) {
      Relationship rel=wmlPackage.getMainDocumentPart().getRelationshipsPart().getRelationshipByID(imgRelId);
      if (rel.getTargetMode() == null || rel.getTargetMode().equals("String_Node_Str")) {
        Part part=wmlPackage.getMainDocumentPart().getRelationshipsPart().getPart(rel);
        try {
          if (imageDirPath.equals("String_Node_Str")) {
            java.nio.ByteBuffer bb=((BinaryPart)part).getBuffer();
            bb.clear();
            byte[] bytes=new byte[bb.capacity()];
            bb.get(bytes,0,bytes.length);
            byte[] encoded=Base64.encodeBase64(bytes,true);
            picture.setSrc("String_Node_Str" + part.getContentType() + "String_Node_Str"+ (new String(encoded,"String_Node_Str")));
          }
 else {
            FileObject folder=getFileSystemManager().resolveFile(imageDirPath);
            if (!folder.exists()) {
              folder.createFolder();
            }
            String partname=part.getPartName().toString();
            String filename=partname.substring(partname.lastIndexOf("String_Node_Str") + 1);
            log.debug("String_Node_Str" + filename);
            FileObject fo=folder.resolveFile(filename);
            if (fo.exists()) {
              log.warn("String_Node_Str");
            }
 else {
              fo.createFile();
            }
            OutputStream out=fo.getContent().getOutputStream();
            try {
              java.nio.ByteBuffer bb=((BinaryPart)part).getBuffer();
              bb.clear();
              byte[] bytes=new byte[bb.capacity()];
              bb.get(bytes,0,bytes.length);
              out.write(bytes);
              String src=fixImgSrcURL(fo);
              picture.setSrc(src);
              log.info("String_Node_Str" + src);
            }
  finally {
              try {
                fo.close();
              }
 catch (              IOException ioe) {
                ioe.printStackTrace();
              }
            }
          }
        }
 catch (        Exception e) {
          e.printStackTrace();
          log.error(e);
        }
      }
 else {
        picture.setSrc(rel.getTarget());
      }
    }
  }
  return picture;
}