Program: 29299
Project: 29299
Buggy source:
/** 
 * Handles a SAX event.
 * @param event
 * @throws SAXException
 */
private void handleEvent(XMLEvent event) throws SAXException {
  if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
    Characters c=event.asCharacters();
    lastContents+=c.getData();
  }
 else   if (event.getEventType() == XMLStreamConstants.START_ELEMENT && isSpreadsheetTag(event.asStartElement().getName())) {
    StartElement startElement=event.asStartElement();
    String tagLocalName=startElement.getName().getLocalPart();
    if ("String_Node_Str".equals(tagLocalName)) {
      Attribute rowNumAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      Attribute isHiddenAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      int rowIndex=Integer.parseInt(rowNumAttr.getValue()) - 1;
      boolean isHidden=isHiddenAttr != null && ("String_Node_Str".equals(isHiddenAttr.getValue()) || "String_Node_Str".equals(isHiddenAttr.getValue()));
      currentRow=new StreamingRow(rowIndex,isHidden);
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute isHiddenAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      boolean isHidden=isHiddenAttr != null && ("String_Node_Str".equals(isHiddenAttr.getValue()) || "String_Node_Str".equals(isHiddenAttr.getValue()));
      if (isHidden) {
        Attribute minAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
        Attribute maxAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
        int min=Integer.parseInt(minAttr.getValue()) - 1;
        int max=Integer.parseInt(maxAttr.getValue()) - 1;
        for (int columnIndex=min; columnIndex <= max; columnIndex++)         hiddenColumns.add(columnIndex);
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute ref=startElement.getAttributeByName(new QName("String_Node_Str"));
      String[] coord=ref.getValue().split("String_Node_Str");
      currentCell=new StreamingCell(CellReference.convertColStringToIndex(coord[0]),Integer.parseInt(coord[1]) - 1,use1904Dates);
      setFormatString(startElement,currentCell);
      Attribute type=startElement.getAttributeByName(new QName("String_Node_Str"));
      if (type != null) {
        currentCell.setType(type.getValue());
      }
 else {
        currentCell.setType("String_Node_Str");
      }
      Attribute style=startElement.getAttributeByName(new QName("String_Node_Str"));
      if (style != null) {
        String indexStr=style.getValue();
        try {
          int index=Integer.parseInt(indexStr);
          currentCell.setCellStyle(stylesTable.getStyleAt(index));
        }
 catch (        NumberFormatException nfe) {
          log.warn("String_Node_Str",indexStr);
        }
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute refAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      String ref=refAttr != null ? refAttr.getValue() : null;
      if (ref != null) {
        for (int i=ref.length() - 1; i >= 0; i--) {
          if (!Character.isDigit(ref.charAt(i))) {
            try {
              lastRowNum=Integer.parseInt(ref.substring(i + 1)) - 1;
            }
 catch (            NumberFormatException ignore) {
            }
            break;
          }
        }
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentCell.setType("String_Node_Str");
    }
    lastContents="String_Node_Str";
  }
 else   if (event.getEventType() == XMLStreamConstants.END_ELEMENT && isSpreadsheetTag(event.asEndElement().getName())) {
    EndElement endElement=event.asEndElement();
    String tagLocalName=endElement.getName().getLocalPart();
    if ("String_Node_Str".equals(tagLocalName) || "String_Node_Str".equals(tagLocalName)) {
      currentCell.setRawContents(unformattedContents());
      currentCell.setContents(formattedContents());
    }
 else     if ("String_Node_Str".equals(tagLocalName) && currentRow != null) {
      rowCache.add(currentRow);
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentRow.getCellMap().put(currentCell.getColumnIndex(),currentCell);
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentCell.setFormula(lastContents);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles a SAX event.
 * @param event
 * @throws SAXException
 */
private void handleEvent(XMLEvent event) throws SAXException {
  if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
    Characters c=event.asCharacters();
    lastContents+=c.getData();
  }
 else   if (event.getEventType() == XMLStreamConstants.START_ELEMENT && isSpreadsheetTag(event.asStartElement().getName())) {
    StartElement startElement=event.asStartElement();
    String tagLocalName=startElement.getName().getLocalPart();
    if ("String_Node_Str".equals(tagLocalName)) {
      Attribute rowNumAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      int rowIndex=currentRowNum;
      if (rowNumAttr != null) {
        rowIndex=Integer.parseInt(rowNumAttr.getValue()) - 1;
        currentRowNum=rowIndex;
      }
      Attribute isHiddenAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      boolean isHidden=isHiddenAttr != null && ("String_Node_Str".equals(isHiddenAttr.getValue()) || "String_Node_Str".equals(isHiddenAttr.getValue()));
      currentRow=new StreamingRow(rowIndex,isHidden);
      currentColNum=firstColNum;
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute isHiddenAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      boolean isHidden=isHiddenAttr != null && ("String_Node_Str".equals(isHiddenAttr.getValue()) || "String_Node_Str".equals(isHiddenAttr.getValue()));
      if (isHidden) {
        Attribute minAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
        Attribute maxAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
        int min=Integer.parseInt(minAttr.getValue()) - 1;
        int max=Integer.parseInt(maxAttr.getValue()) - 1;
        for (int columnIndex=min; columnIndex <= max; columnIndex++)         hiddenColumns.add(columnIndex);
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute ref=startElement.getAttributeByName(new QName("String_Node_Str"));
      if (ref != null) {
        String[] coord=ref.getValue().split("String_Node_Str");
        currentCell=new StreamingCell(CellReference.convertColStringToIndex(coord[0]),Integer.parseInt(coord[1]) - 1,use1904Dates);
      }
 else {
        currentCell=new StreamingCell(currentColNum,currentRowNum,use1904Dates);
      }
      setFormatString(startElement,currentCell);
      Attribute type=startElement.getAttributeByName(new QName("String_Node_Str"));
      if (type != null) {
        currentCell.setType(type.getValue());
      }
 else {
        currentCell.setType("String_Node_Str");
      }
      Attribute style=startElement.getAttributeByName(new QName("String_Node_Str"));
      if (style != null) {
        String indexStr=style.getValue();
        try {
          int index=Integer.parseInt(indexStr);
          currentCell.setCellStyle(stylesTable.getStyleAt(index));
        }
 catch (        NumberFormatException nfe) {
          log.warn("String_Node_Str",indexStr);
        }
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      Attribute refAttr=startElement.getAttributeByName(new QName("String_Node_Str"));
      String ref=refAttr != null ? refAttr.getValue() : null;
      if (ref != null) {
        for (int i=ref.length() - 1; i >= 0; i--) {
          if (!Character.isDigit(ref.charAt(i))) {
            try {
              lastRowNum=Integer.parseInt(ref.substring(i + 1)) - 1;
            }
 catch (            NumberFormatException ignore) {
            }
            break;
          }
        }
        for (int i=0; i < ref.length(); i++) {
          if (!Character.isAlphabetic(ref.charAt(i))) {
            firstColNum=CellReference.convertColStringToIndex(ref.substring(0,i));
            break;
          }
        }
      }
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentCell.setType("String_Node_Str");
    }
    lastContents="String_Node_Str";
  }
 else   if (event.getEventType() == XMLStreamConstants.END_ELEMENT && isSpreadsheetTag(event.asEndElement().getName())) {
    EndElement endElement=event.asEndElement();
    String tagLocalName=endElement.getName().getLocalPart();
    if ("String_Node_Str".equals(tagLocalName) || "String_Node_Str".equals(tagLocalName)) {
      currentCell.setRawContents(unformattedContents());
      currentCell.setContents(formattedContents());
    }
 else     if ("String_Node_Str".equals(tagLocalName) && currentRow != null) {
      rowCache.add(currentRow);
      currentRowNum++;
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentRow.getCellMap().put(currentCell.getColumnIndex(),currentCell);
      currentColNum++;
    }
 else     if ("String_Node_Str".equals(tagLocalName)) {
      currentCell.setFormula(lastContents);
    }
  }
}