Program: 91856
Project: 91856
Buggy source:
private void createXML(){
  Element oldImage=(Element)oldRoot.getElementsByTagName(BINARY).item(0);
  Element newImage=newDoc.createElement(IMAGE);
  String binName=oldImage.getAttribute(NAME);
  newImage.setAttribute(NAME,binName);
  Element countTag=(Element)oldImage.getElementsByTagName(COUNT).item(0);
  String imageCount=countTag.getTextContent().trim();
  newImage.setAttribute(COUNT,imageCount);
  if (!InfoAdapter.hasTimerSupport()) {
    Element setupTag=(Element)oldRoot.getElementsByTagName(SETUP).item(0);
    Element eventSetupTag=(Element)setupTag.getElementsByTagName(EVENT_SETUP).item(0);
    String setupcount=eventSetupTag.getAttribute(SETUP_COUNT);
    newImage.setAttribute(SETUP_COUNT,setupcount);
  }
  Element oldSymbolTableTag=(Element)oldRoot.getElementsByTagName(SYMBOL_TABLE).item(0);
  NodeList oldSymbolDataList=oldSymbolTableTag.getElementsByTagName(SYMBOL_DATA);
  Element oldDetailTableTag=(Element)oldRoot.getElementsByTagName(DETAIL_TABLE).item(0);
  NodeList oldDetailTableList=oldDetailTableTag.getElementsByTagName(SYMBOL_DETAILS);
  HashMap<String,HashMap<String,String>> oldSymbolDataListMap=parseDataList(oldSymbolDataList);
  HashMap<String,NodeList> oldDetailTableListMap=parseDetailTable(oldDetailTableList);
  ArrayList<Element> oldImageList=new ArrayList<>();
  oldImageList.add(oldImage);
  NodeList oldModuleList=oldImage.getElementsByTagName(MODULE);
  Element dependentTag=newDoc.createElement(DEPENDENT);
  if (oldModuleList.getLength() > 0) {
    dependentTag.setAttribute(COUNT,"String_Node_Str");
    for (int t=0; t < oldModuleList.getLength(); t++) {
      oldImageList.add((Element)oldModuleList.item(t));
    }
  }
  for (  Element oldImg : oldImageList) {
    Element newImg;
    if (oldImg.getTagName().equals(BINARY)) {
      newImg=newImage;
    }
 else {
      newImg=newDoc.createElement(IMAGE);
      String imgName=oldImg.getAttribute(NAME);
      newImg.setAttribute(NAME,imgName);
      Element modCountTag=(Element)oldImg.getElementsByTagName(COUNT).item(0);
      String imgCount=modCountTag.getTextContent().trim();
      newImg.setAttribute(COUNT,imgCount);
    }
    Element newSymbolsTag=newDoc.createElement(SYMBOLS);
    NodeList oldSymbolList=oldImg.getElementsByTagName(SYMBOL);
    for (int i=0; i < oldSymbolList.getLength(); i++) {
      Element oldSymbol=(Element)oldSymbolList.item(i);
      if (!oldSymbol.getParentNode().isSameNode(oldImg)) {
        continue;
      }
      Element newSymbol=newDoc.createElement(SYMBOL);
      String idref=oldSymbol.getAttribute(IDREF);
      String symbolCount=((Element)oldSymbol.getElementsByTagName(COUNT).item(0)).getTextContent().trim();
      newSymbol.setAttribute(COUNT,symbolCount);
      HashMap<String,String> symbolData=oldSymbolDataListMap.get(idref);
      newSymbol.setAttribute(NAME,symbolData.get(NAME));
      newSymbol.setAttribute(FILE,symbolData.get(FILE));
      newSymbol.setAttribute(LINE,symbolData.get(LINE));
      NodeList detailDataList=oldDetailTableListMap.get(idref);
      HashMap<String,Element> tmp=new HashMap<>();
      TreeSet<Element> sorted=new TreeSet<>(SAMPLE_COUNT_ORDER);
      for (int l=0; l < detailDataList.getLength(); l++) {
        Element detailData=(Element)detailDataList.item(l);
        String sampleFile=detailData.getAttribute(FILE);
        String sampleLine=detailData.getAttribute(LINE);
        if (sampleFile.equals("String_Node_Str") && !sampleLine.equals("String_Node_Str")) {
          sampleFile=symbolData.get(FILE);
        }
 else {
          if (sampleFile.equals("String_Node_Str")) {
            sampleFile="String_Node_Str";
          }
          if (sampleLine.equals("String_Node_Str")) {
            sampleLine="String_Node_Str";
          }
        }
        Element detailDataCount=(Element)detailData.getElementsByTagName(COUNT).item(0);
        String count=detailDataCount.getTextContent().trim();
        if (tmp.containsKey(sampleLine)) {
          Element elem=(Element)tmp.get(sampleLine).getElementsByTagName(COUNT).item(0);
          int val=Integer.parseInt(elem.getTextContent().trim()) + Integer.parseInt(count);
          elem.setTextContent(String.valueOf(val));
        }
 else {
          Element sampleTag=newDoc.createElement(SAMPLE);
          Element fileTag=newDoc.createElement(FILE);
          fileTag.setTextContent(sampleFile);
          Element lineTag=newDoc.createElement(LINE);
          lineTag.setTextContent(sampleLine);
          Element sampleCountTag=newDoc.createElement(COUNT);
          sampleCountTag.setTextContent(count);
          sampleTag.appendChild(fileTag);
          sampleTag.appendChild(lineTag);
          sampleTag.appendChild(sampleCountTag);
          tmp.put(sampleLine,sampleTag);
        }
      }
      for (      Element elem : tmp.values()) {
        sorted.add(elem);
      }
      for (      Element e : sorted) {
        newSymbol.appendChild(e);
      }
      newSymbolsTag.appendChild(newSymbol);
    }
    newImg.appendChild(newSymbolsTag);
    if (oldImg.getTagName().equals(MODULE)) {
      dependentTag.appendChild(newImg);
      int currVal=Integer.parseInt(dependentTag.getAttribute(COUNT));
      int val=Integer.parseInt(newImg.getAttribute(COUNT));
      dependentTag.setAttribute(COUNT,String.valueOf(currVal + val));
    }
 else {
      newRoot.appendChild(newImg);
    }
  }
  if (oldModuleList.getLength() > 0) {
    newImage.appendChild(dependentTag);
  }
}

Fixed version (ground truth):
private void createXML(){
  Element oldImage=(Element)oldRoot.getElementsByTagName(BINARY).item(0);
  Element newImage=newDoc.createElement(IMAGE);
  String binName=oldImage.getAttribute(NAME);
  newImage.setAttribute(NAME,binName);
  Element countTag=(Element)oldImage.getElementsByTagName(COUNT).item(0);
  String imageCount=countTag.getTextContent().trim();
  newImage.setAttribute(COUNT,imageCount);
  if (!InfoAdapter.hasTimerSupport()) {
    Element setupTag=(Element)oldRoot.getElementsByTagName(SETUP).item(0);
    Element eventSetupTag=(Element)setupTag.getElementsByTagName(EVENT_SETUP).item(0);
    String setupcount=eventSetupTag.getAttribute(SETUP_COUNT);
    newImage.setAttribute(SETUP_COUNT,setupcount);
  }
  Element oldSymbolTableTag=(Element)oldRoot.getElementsByTagName(SYMBOL_TABLE).item(0);
  NodeList oldSymbolDataList=oldSymbolTableTag.getElementsByTagName(SYMBOL_DATA);
  Element oldDetailTableTag=(Element)oldRoot.getElementsByTagName(DETAIL_TABLE).item(0);
  NodeList oldDetailTableList=oldDetailTableTag.getElementsByTagName(SYMBOL_DETAILS);
  HashMap<String,HashMap<String,String>> oldSymbolDataListMap=parseDataList(oldSymbolDataList);
  HashMap<String,NodeList> oldDetailTableListMap=parseDetailTable(oldDetailTableList);
  ArrayList<Element> oldImageList=new ArrayList<>();
  oldImageList.add(oldImage);
  NodeList oldModuleList=oldImage.getElementsByTagName(MODULE);
  Element dependentTag=newDoc.createElement(DEPENDENT);
  if (oldModuleList.getLength() > 0) {
    dependentTag.setAttribute(COUNT,"String_Node_Str");
    for (int t=0; t < oldModuleList.getLength(); t++) {
      oldImageList.add((Element)oldModuleList.item(t));
    }
  }
  for (  Element oldImg : oldImageList) {
    Element newImg;
    if (oldImg.getTagName().equals(BINARY)) {
      newImg=newImage;
    }
 else {
      newImg=newDoc.createElement(IMAGE);
      String imgName=oldImg.getAttribute(NAME);
      newImg.setAttribute(NAME,imgName);
      Element modCountTag=(Element)oldImg.getElementsByTagName(COUNT).item(0);
      String imgCount=modCountTag.getTextContent().trim();
      newImg.setAttribute(COUNT,imgCount);
    }
    Element newSymbolsTag=newDoc.createElement(SYMBOLS);
    NodeList oldSymbolList=oldImg.getElementsByTagName(SYMBOL);
    for (int i=0; i < oldSymbolList.getLength(); i++) {
      Element oldSymbol=(Element)oldSymbolList.item(i);
      if (!oldSymbol.getParentNode().isSameNode(oldImg)) {
        continue;
      }
      Element newSymbol=newDoc.createElement(SYMBOL);
      String idref=oldSymbol.getAttribute(IDREF);
      String symbolCount=((Element)oldSymbol.getElementsByTagName(COUNT).item(0)).getTextContent().trim();
      newSymbol.setAttribute(COUNT,symbolCount);
      HashMap<String,String> symbolData=oldSymbolDataListMap.get(idref);
      newSymbol.setAttribute(NAME,symbolData.get(NAME));
      newSymbol.setAttribute(FILE,symbolData.get(FILE));
      newSymbol.setAttribute(LINE,symbolData.get(LINE));
      NodeList detailDataList=oldDetailTableListMap.get(idref);
      HashMap<String,Element> tmp=new HashMap<>();
      TreeSet<Element> sorted=new TreeSet<>(SAMPLE_COUNT_ORDER);
      for (int l=0; l < detailDataList.getLength(); l++) {
        Element detailData=(Element)detailDataList.item(l);
        String sampleFile=detailData.getAttribute(FILE);
        String sampleLine=detailData.getAttribute(LINE);
        if (sampleFile.equals("String_Node_Str") && !sampleLine.isEmpty()) {
          sampleFile=symbolData.get(FILE);
        }
 else {
          if (sampleFile.equals("String_Node_Str")) {
            sampleFile="String_Node_Str";
          }
          if (sampleLine.equals("String_Node_Str")) {
            sampleLine="String_Node_Str";
          }
        }
        Element detailDataCount=(Element)detailData.getElementsByTagName(COUNT).item(0);
        String count=detailDataCount.getTextContent().trim();
        if (tmp.containsKey(sampleLine)) {
          Element elem=(Element)tmp.get(sampleLine).getElementsByTagName(COUNT).item(0);
          int val=Integer.parseInt(elem.getTextContent().trim()) + Integer.parseInt(count);
          elem.setTextContent(String.valueOf(val));
        }
 else {
          Element sampleTag=newDoc.createElement(SAMPLE);
          Element fileTag=newDoc.createElement(FILE);
          fileTag.setTextContent(sampleFile);
          Element lineTag=newDoc.createElement(LINE);
          lineTag.setTextContent(sampleLine);
          Element sampleCountTag=newDoc.createElement(COUNT);
          sampleCountTag.setTextContent(count);
          sampleTag.appendChild(fileTag);
          sampleTag.appendChild(lineTag);
          sampleTag.appendChild(sampleCountTag);
          tmp.put(sampleLine,sampleTag);
        }
      }
      for (      Element elem : tmp.values()) {
        sorted.add(elem);
      }
      for (      Element e : sorted) {
        newSymbol.appendChild(e);
      }
      newSymbolsTag.appendChild(newSymbol);
    }
    newImg.appendChild(newSymbolsTag);
    if (oldImg.getTagName().equals(MODULE)) {
      dependentTag.appendChild(newImg);
      int currVal=Integer.parseInt(dependentTag.getAttribute(COUNT));
      int val=Integer.parseInt(newImg.getAttribute(COUNT));
      dependentTag.setAttribute(COUNT,String.valueOf(currVal + val));
    }
 else {
      newRoot.appendChild(newImg);
    }
  }
  if (oldModuleList.getLength() > 0) {
    newImage.appendChild(dependentTag);
  }
}