Program: 185091
Project: 185091
Buggy source:
public static DocumentFragment xpathInjectImage(WordprocessingMLPackage wmlPackage,JaxbXmlPart sourcePart,Map<String,CustomXmlDataStoragePart> customXmlDataStorageParts,String storeItemId,String xpath,String prefixMappings,String sdtParent,String contentChild,String cx,String cy){
  log.debug("String_Node_Str" + sdtParent);
  CustomXmlDataStoragePart part=customXmlDataStorageParts.get(storeItemId.toLowerCase());
  if (part == null) {
    log.error("String_Node_Str" + storeItemId);
    return null;
  }
  try {
    String r=part.getData().xpathGetString(xpath,prefixMappings);
    log.debug(xpath + "String_Node_Str" + r);
    byte[] bytes=Base64.decodeBase64(r.getBytes("String_Node_Str"));
    BinaryPartAbstractImage imagePart=BinaryPartAbstractImage.createImagePart(wmlPackage,sourcePart,bytes);
    String filenameHint=null;
    String altText=null;
    int id1=0;
    int id2=1;
    Inline inline=null;
    long cxl=0;
    long cyl=0;
    try {
      cxl=Long.parseLong(cx);
      cyl=Long.parseLong(cy);
    }
 catch (    Exception e) {
    }
    if (cxl == 0 || cyl == 0) {
      log.debug("String_Node_Str");
      inline=imagePart.createImageInline(filenameHint,altText,id1,id2,false);
    }
 else {
      log.debug("String_Node_Str");
      ImageSize size=imagePart.getImageInfo().getSize();
      double ratio=(double)size.getHeightPx() / (double)size.getWidthPx();
      log.debug("String_Node_Str" + ratio);
      if (ratio > 1) {
        cxl=(long)((double)cyl / ratio);
      }
 else {
        cyl=(long)((double)cxl * ratio);
      }
      inline=imagePart.createImageInline(filenameHint,altText,id1,id2,cxl,cyl,false);
    }
    org.docx4j.wml.ObjectFactory factory=new org.docx4j.wml.ObjectFactory();
    org.docx4j.wml.Tc tc=factory.createTc();
    org.docx4j.wml.P p=factory.createP();
    if (sdtParent.equals("String_Node_Str")) {
      tc.getContent().add(p);
    }
    org.docx4j.wml.R run=factory.createR();
    if (sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str")) {
      p.getContent().add(run);
    }
    org.docx4j.wml.Drawing drawing=factory.createDrawing();
    run.getContent().add(drawing);
    drawing.getAnchorOrInline().add(inline);
    Document document=null;
    if (sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(p);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(tc);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(run);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      log.info("String_Node_Str" + contentChild);
      if (contentChild.equals("String_Node_Str")) {
        p.getContent().add(run);
        document=XmlUtils.marshaltoW3CDomDocument(p);
      }
 else       if (contentChild.equals("String_Node_Str")) {
        document=XmlUtils.marshaltoW3CDomDocument(r);
      }
 else {
        log.error("String_Node_Str" + contentChild);
      }
    }
 else {
      log.error("String_Node_Str" + sdtParent);
    }
    DocumentFragment docfrag=document.createDocumentFragment();
    docfrag.appendChild(document.getDocumentElement());
    return docfrag;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}

Fixed version (ground truth):
public static DocumentFragment xpathInjectImage(WordprocessingMLPackage wmlPackage,JaxbXmlPart sourcePart,Map<String,CustomXmlDataStoragePart> customXmlDataStorageParts,String storeItemId,String xpath,String prefixMappings,String sdtParent,String contentChild,String cx,String cy){
  log.debug("String_Node_Str" + sdtParent);
  CustomXmlDataStoragePart part=customXmlDataStorageParts.get(storeItemId.toLowerCase());
  if (part == null) {
    log.error("String_Node_Str" + storeItemId);
    return null;
  }
  try {
    String xpResult=part.getData().xpathGetString(xpath,prefixMappings);
    log.debug(xpath + "String_Node_Str" + xpResult);
    byte[] bytes=Base64.decodeBase64(xpResult.getBytes("String_Node_Str"));
    BinaryPartAbstractImage imagePart=BinaryPartAbstractImage.createImagePart(wmlPackage,sourcePart,bytes);
    String filenameHint=null;
    String altText=null;
    int id1=0;
    int id2=1;
    Inline inline=null;
    long cxl=0;
    long cyl=0;
    try {
      cxl=Long.parseLong(cx);
      cyl=Long.parseLong(cy);
    }
 catch (    Exception e) {
    }
    if (cxl == 0 || cyl == 0) {
      log.debug("String_Node_Str");
      inline=imagePart.createImageInline(filenameHint,altText,id1,id2,false);
    }
 else {
      log.debug("String_Node_Str");
      ImageSize size=imagePart.getImageInfo().getSize();
      double ratio=(double)size.getHeightPx() / (double)size.getWidthPx();
      log.debug("String_Node_Str" + ratio);
      if (ratio > 1) {
        cxl=(long)((double)cyl / ratio);
      }
 else {
        cyl=(long)((double)cxl * ratio);
      }
      inline=imagePart.createImageInline(filenameHint,altText,id1,id2,cxl,cyl,false);
    }
    org.docx4j.wml.ObjectFactory factory=new org.docx4j.wml.ObjectFactory();
    org.docx4j.wml.Tc tc=factory.createTc();
    org.docx4j.wml.P p=factory.createP();
    if (sdtParent.equals("String_Node_Str")) {
      tc.getContent().add(p);
    }
    org.docx4j.wml.R run=factory.createR();
    if (sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str")) {
      p.getContent().add(run);
    }
    org.docx4j.wml.Drawing drawing=factory.createDrawing();
    run.getContent().add(drawing);
    drawing.getAnchorOrInline().add(inline);
    Document document=null;
    if (sdtParent.equals("String_Node_Str") || sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(p);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(tc);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      document=XmlUtils.marshaltoW3CDomDocument(run);
    }
 else     if (sdtParent.equals("String_Node_Str")) {
      log.info("String_Node_Str" + contentChild);
      if (contentChild.equals("String_Node_Str")) {
        p.getContent().add(run);
        document=XmlUtils.marshaltoW3CDomDocument(p);
      }
 else       if (contentChild.equals("String_Node_Str")) {
        document=XmlUtils.marshaltoW3CDomDocument(run);
      }
 else {
        log.error("String_Node_Str" + contentChild);
      }
    }
 else {
      log.error("String_Node_Str" + sdtParent);
    }
    DocumentFragment docfrag=document.createDocumentFragment();
    docfrag.appendChild(document.getDocumentElement());
    return docfrag;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return null;
  }
}