Program: 152628
Project: 152628
Buggy source:
/** 
 * @param byteBuffer
 * @param charsetDecoder
 * @return the new particle or NULL, if the buffer was exhausted before the particle was completed
 * @throws Exception
 */
public void parse(IoBuffer byteBuffer,CharsetDecoder decoder) throws SAXException {
  lastPosition=byteBuffer.position();
  while (byteBuffer.hasRemaining() && state != State.CLOSED) {
    char c=(char)byteBuffer.get();
    if (state == State.START) {
      if (c == '<') {
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else {
        state=State.IN_TEXT;
      }
    }
 else     if (state == State.IN_TEXT) {
      if (c == '<') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
    }
 else     if (state == State.IN_TAG) {
      if (c == '>') {
        emit(c,byteBuffer);
        state=State.START;
      }
 else       if (c == '"') {
        emit(c,byteBuffer);
        state=State.IN_DOUBLE_ATTRIBUTE_VALUE;
      }
 else       if (c == '\'') {
        emit(c,byteBuffer);
        state=State.IN_SINGLE_ATTRIBUTE_VALUE;
      }
 else       if (c == '-') {
        emit(c,byteBuffer);
      }
 else       if (isControlChar(c)) {
        emit(c,byteBuffer);
      }
 else       if (Character.isWhitespace(c)) {
        lastPosition=byteBuffer.position();
      }
 else {
        state=State.IN_STRING;
      }
    }
 else     if (state == State.IN_STRING) {
      if (c == '>') {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        emit(c,byteBuffer);
        state=State.START;
      }
 else       if (isControlChar(c)) {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else       if (Character.isWhitespace(c)) {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        state=State.IN_TAG;
      }
 else {
      }
    }
 else     if (state == State.IN_DOUBLE_ATTRIBUTE_VALUE) {
      if (c == '"') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
    }
 else     if (state == State.IN_SINGLE_ATTRIBUTE_VALUE) {
      if (c == '\'') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
    }
  }
  byteBuffer.position(lastPosition);
}

Fixed version (ground truth):
/** 
 * @param byteBuffer
 * @param charsetDecoder
 * @return the new particle or NULL, if the buffer was exhausted before the particle was completed
 * @throws Exception
 */
public void parse(IoBuffer byteBuffer,CharsetDecoder decoder) throws SAXException {
  while (byteBuffer.hasRemaining() && state != State.CLOSED) {
    char c=(char)byteBuffer.get();
    if (state == State.START) {
      if (c == '<') {
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else {
        state=State.IN_TEXT;
        buffer.put((byte)c);
      }
    }
 else     if (state == State.IN_TEXT) {
      if (c == '<') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else {
        buffer.put((byte)c);
      }
    }
 else     if (state == State.IN_TAG) {
      if (c == '>') {
        emit(c,byteBuffer);
        state=State.START;
      }
 else       if (c == '"') {
        emit(c,byteBuffer);
        state=State.IN_DOUBLE_ATTRIBUTE_VALUE;
      }
 else       if (c == '\'') {
        emit(c,byteBuffer);
        state=State.IN_SINGLE_ATTRIBUTE_VALUE;
      }
 else       if (c == '-') {
        emit(c,byteBuffer);
      }
 else       if (isControlChar(c)) {
        emit(c,byteBuffer);
      }
 else       if (Character.isWhitespace(c)) {
        buffer.clear();
      }
 else {
        state=State.IN_STRING;
        buffer.put((byte)c);
      }
    }
 else     if (state == State.IN_STRING) {
      if (c == '>') {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        emit(c,byteBuffer);
        state=State.START;
      }
 else       if (isControlChar(c)) {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else       if (Character.isWhitespace(c)) {
        emit(byteBuffer,CharsetUtil.UTF8_DECODER);
        state=State.IN_TAG;
      }
 else {
        buffer.put((byte)c);
      }
    }
 else     if (state == State.IN_DOUBLE_ATTRIBUTE_VALUE) {
      if (c == '"') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else {
        buffer.put((byte)c);
      }
    }
 else     if (state == State.IN_SINGLE_ATTRIBUTE_VALUE) {
      if (c == '\'') {
        emit(byteBuffer,decoder);
        emit(c,byteBuffer);
        state=State.IN_TAG;
      }
 else {
        buffer.put((byte)c);
      }
    }
  }
}