Program: 185104
Project: 185104
Buggy source:
private static void processDescendantBindings(Object sdt,String xpathBase,int index){
  SdtPr sdtPr=getSdtPr(sdt);
  sdtPr.setId();
  CTDataBinding binding=(CTDataBinding)XmlUtils.unwrap(sdtPr.getDataBinding());
  String thisXPath=null;
  String conditionId=null;
  String repeatId=null;
  String bindingId=null;
  Condition c=null;
  org.opendope.xpaths.Xpaths.Xpath xpathObj=null;
  Tag tag=sdtPr.getTag();
  HashMap<String,String> map=QueryString.parseQueryString(tag.getVal(),true);
  if (binding == null) {
    conditionId=map.get(BINDING_ROLE_CONDITIONAL);
    repeatId=map.get(BINDING_ROLE_REPEAT);
    if (conditionId != null) {
      c=ConditionsPart.getConditionById(conditions,conditionId);
      xpathObj=getXPathFromCondition(c);
      thisXPath=xpathObj.getDataBinding().getXpath();
    }
 else     if (repeatId != null) {
      xpathObj=XPathsPart.getXPathById(xPaths,repeatId);
      thisXPath=xpathObj.getDataBinding().getXpath();
    }
 else {
      log.warn("String_Node_Str");
      return;
    }
  }
 else {
    thisXPath=binding.getXpath();
    bindingId=map.get(BINDING_ROLE_XPATH);
    xpathObj=XPathsPart.getXPathById(xPaths,bindingId);
    if (!thisXPath.equals(xpathObj.getDataBinding().getXpath())) {
      log.error("String_Node_Str" + bindingId + "String_Node_Str"+ xpathObj.getDataBinding().getXpath());
    }
  }
  log.debug("String_Node_Str" + thisXPath);
  if (thisXPath.startsWith(xpathBase)) {
    log.debug("String_Node_Str" + xpathBase);
    int beginIndex=thisXPath.indexOf("String_Node_Str",xpathBase.length() - 1);
    int endIndex=thisXPath.indexOf("String_Node_Str",beginIndex);
    String newPath;
    if (endIndex < 0) {
      newPath=thisXPath + "String_Node_Str" + (index + 1)+ "String_Node_Str";
    }
 else {
      String startBit=thisXPath.substring(0,endIndex);
      if (startBit.endsWith("String_Node_Str"))       startBit=startBit.substring(0,startBit.lastIndexOf("String_Node_Str"));
      newPath=startBit + "String_Node_Str" + (index + 1)+ "String_Node_Str"+ thisXPath.substring(endIndex + 1);
    }
    log.debug("String_Node_Str" + newPath + "String_Node_Str");
    if (binding == null) {
      if (conditionId != null) {
        Condition newCondition=XmlUtils.deepCopy(c);
        String newConditionId=conditionId + "String_Node_Str" + index;
        newCondition.setId(newConditionId);
        conditions.getCondition().add(newCondition);
        map.put(BINDING_ROLE_CONDITIONAL,newConditionId);
        tag.setVal(QueryString.create(map));
        org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
        newCondition.getXpathref().setId(newXPathObj.getId());
      }
 else       if (repeatId != null) {
        org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
        map.put(BINDING_ROLE_REPEAT,newXPathObj.getId());
        tag.setVal(QueryString.create(map));
      }
    }
 else {
      binding.setXpath(newPath);
      org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
      map.put(BINDING_ROLE_XPATH,newXPathObj.getId());
      tag.setVal(QueryString.create(map));
    }
  }
 else {
    log.debug("String_Node_Str" + xpathBase + "String_Node_Str");
  }
}

Fixed version (ground truth):
private static void processDescendantBindings(Object sdt,String xpathBase,int index){
  SdtPr sdtPr=getSdtPr(sdt);
  sdtPr.setId();
  CTDataBinding binding=(CTDataBinding)XmlUtils.unwrap(sdtPr.getDataBinding());
  String thisXPath=null;
  String conditionId=null;
  String repeatId=null;
  String bindingId=null;
  Condition c=null;
  org.opendope.xpaths.Xpaths.Xpath xpathObj=null;
  Tag tag=sdtPr.getTag();
  HashMap<String,String> map=QueryString.parseQueryString(tag.getVal(),true);
  if (binding == null) {
    conditionId=map.get(BINDING_ROLE_CONDITIONAL);
    repeatId=map.get(BINDING_ROLE_REPEAT);
    if (conditionId != null) {
      c=ConditionsPart.getConditionById(conditions,conditionId);
      if (c == null) {
        log.error("String_Node_Str" + conditionId);
      }
      log.debug("String_Node_Str" + XmlUtils.marshaltoString(c,true,true));
      xpathObj=getXPathFromCondition(c);
      thisXPath=xpathObj.getDataBinding().getXpath();
    }
 else     if (repeatId != null) {
      xpathObj=XPathsPart.getXPathById(xPaths,repeatId);
      thisXPath=xpathObj.getDataBinding().getXpath();
    }
 else {
      log.warn("String_Node_Str");
      return;
    }
  }
 else {
    thisXPath=binding.getXpath();
    bindingId=map.get(BINDING_ROLE_XPATH);
    xpathObj=XPathsPart.getXPathById(xPaths,bindingId);
    if (!thisXPath.equals(xpathObj.getDataBinding().getXpath())) {
      log.error("String_Node_Str" + bindingId + "String_Node_Str"+ xpathObj.getDataBinding().getXpath());
    }
  }
  log.debug("String_Node_Str" + thisXPath);
  if (!thisXPath.startsWith(xpathBase)) {
    log.debug("String_Node_Str" + xpathBase + "String_Node_Str");
    return;
  }
  log.debug("String_Node_Str" + xpathBase);
  int beginIndex=thisXPath.indexOf("String_Node_Str",xpathBase.length() - 1);
  int endIndex=-2;
  if (beginIndex > 0) {
    endIndex=thisXPath.indexOf("String_Node_Str",beginIndex);
  }
  log.debug("String_Node_Str" + beginIndex);
  log.debug("String_Node_Str" + endIndex);
  String newPath;
  if (endIndex < beginIndex) {
    String startBit=thisXPath;
    if (startBit.endsWith("String_Node_Str"))     startBit=startBit.substring(0,startBit.lastIndexOf("String_Node_Str"));
    newPath=startBit + "String_Node_Str" + (index + 1)+ "String_Node_Str";
  }
 else {
    String startBit=thisXPath.substring(0,endIndex);
    if (startBit.endsWith("String_Node_Str"))     startBit=startBit.substring(0,startBit.lastIndexOf("String_Node_Str"));
    newPath=startBit + "String_Node_Str" + (index + 1)+ "String_Node_Str"+ thisXPath.substring(endIndex + 1);
  }
  log.debug("String_Node_Str" + newPath + "String_Node_Str");
  if (binding == null) {
    if (conditionId != null) {
      Condition newCondition=XmlUtils.deepCopy(c);
      String newConditionId=conditionId + "String_Node_Str" + index;
      newCondition.setId(newConditionId);
      conditions.getCondition().add(newCondition);
      map.put(BINDING_ROLE_CONDITIONAL,newConditionId);
      tag.setVal(QueryString.create(map));
      org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
      newCondition.getXpathref().setId(newXPathObj.getId());
    }
 else     if (repeatId != null) {
      org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
      map.put(BINDING_ROLE_REPEAT,newXPathObj.getId());
      tag.setVal(QueryString.create(map));
    }
  }
 else {
    binding.setXpath(newPath);
    org.opendope.xpaths.Xpaths.Xpath newXPathObj=createNewXPathObject(newPath,xpathObj,index);
    map.put(BINDING_ROLE_XPATH,newXPathObj.getId());
    tag.setVal(QueryString.create(map));
  }
}