Program: 41080
Project: 41080
Buggy source:
public void input(final ByteBuffer input){
  TransportResult frameParsingError=null;
  int size=_size;
  ByteBuffer nextFramesInput=null;
  byte[] header=new byte[8];
  boolean transportAccepting=true;
  ByteBuffer currentInput=input;
  while (currentInput.hasRemaining() && _state != State.ERROR && transportAccepting) {
switch (_state) {
case HEADER0:
      if (currentInput.hasRemaining()) {
        byte c=currentInput.get();
        header[0]=c;
        _state=State.HEADER1;
      }
 else {
        break;
      }
case HEADER1:
    if (currentInput.hasRemaining()) {
      byte c=currentInput.get();
      header[1]=c;
      _state=State.HEADER2;
    }
 else {
      break;
    }
case HEADER2:
  if (currentInput.hasRemaining()) {
    byte c=currentInput.get();
    header[2]=c;
    _state=State.HEADER3;
  }
 else {
    break;
  }
case HEADER3:
if (currentInput.hasRemaining()) {
  byte c=currentInput.get();
  header[3]=c;
  _state=State.HEADER4;
}
 else {
  break;
}
case HEADER4:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[4]=c;
_state=State.HEADER5;
}
 else {
break;
}
case HEADER5:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[5]=c;
_state=State.HEADER6;
}
 else {
break;
}
case HEADER6:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[6]=c;
_state=State.HEADER7;
}
 else {
break;
}
case HEADER7:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[7]=c;
_peer.receiveHeader(header);
_state=State.SIZE_0;
}
 else {
break;
}
case SIZE_0:
if (!currentInput.hasRemaining()) {
break;
}
if (currentInput.remaining() >= 4) {
size=currentInput.getInt();
_state=State.PRE_PARSE;
break;
}
 else {
size=(currentInput.get() << 24) & 0xFF000000;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_1;
break;
}
}
case SIZE_1:
size|=(currentInput.get() << 16) & 0xFF0000;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_2;
break;
}
case SIZE_2:
size|=(currentInput.get() << 8) & 0xFF00;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_3;
break;
}
case SIZE_3:
size|=currentInput.get() & 0xFF;
_state=State.PRE_PARSE;
case PRE_PARSE:
;
if (size < 8) {
frameParsingError=error("String_Node_Str" + "String_Node_Str",_size,8);
_state=State.ERROR;
break;
}
if (currentInput.remaining() < size - 4) {
_frameBuffer=ByteBuffer.allocate(size - 4);
_frameBuffer.put(currentInput);
_state=State.BUFFERING;
break;
}
case BUFFERING:
if (_frameBuffer != null) {
if (currentInput.remaining() < _frameBuffer.remaining()) {
_frameBuffer.put(currentInput);
break;
}
 else {
ByteBuffer dup=currentInput.duplicate();
dup.limit(dup.position() + _frameBuffer.remaining());
currentInput.position(currentInput.position() + _frameBuffer.remaining());
_frameBuffer.put(dup);
nextFramesInput=currentInput;
_frameBuffer.flip();
currentInput=_frameBuffer;
_state=State.PARSING;
}
}
case PARSING:
int dataOffset=(currentInput.get() << 2) & 0x3FF;
if (dataOffset < 8) {
frameParsingError=error("String_Node_Str",dataOffset,8);
_state=State.ERROR;
break;
}
 else if (dataOffset > size) {
frameParsingError=error("String_Node_Str",dataOffset,_size);
_state=State.ERROR;
break;
}
int type=currentInput.get() & 0xFF;
int channel=currentInput.getShort() & 0xFF;
if (dataOffset != 8) {
currentInput.position(currentInput.position() + dataOffset - 8);
}
final int frameBodySize=size - dataOffset;
if (nextFramesInput == null) {
nextFramesInput=currentInput;
currentInput=currentInput.duplicate();
final int endPos=currentInput.position() + frameBodySize;
currentInput.limit(endPos);
nextFramesInput.position(endPos);
}
try {
if (frameBodySize > 0) {
Data data=Data.Factory.create();
data.decode(currentInput);
Data.DataType dataType=data.type();
if (dataType != Data.DataType.DESCRIBED) {
throw new IllegalArgumentException("String_Node_Str" + Data.DataType.DESCRIBED + "String_Node_Str"+ dataType);
}
DescribedType describedType=data.getDescribedType();
LOGGER.debug("String_Node_Str",describedType);
Binary payload;
if (currentInput.hasRemaining()) {
byte[] payloadBytes=new byte[currentInput.remaining()];
currentInput.get(payloadBytes);
payload=new Binary(payloadBytes);
}
 else {
payload=null;
}
_peer.receiveFrame(type,channel,describedType,payload);
}
 else {
LOGGER.debug("String_Node_Str");
}
_size=0;
currentInput=nextFramesInput;
nextFramesInput=null;
_frameBuffer=null;
if (_state != State.HEADER0) {
_state=State.SIZE_0;
}
}
 catch (DecodeException ex) {
_state=State.ERROR;
frameParsingError=error(ex);
}
break;
case ERROR:
}
}
_size=size;
if (_state == State.ERROR) {
if (frameParsingError != null) {
frameParsingError.checkIsOk();
}
 else {
TransportResultFactory.error("String_Node_Str").checkIsOk();
}
}
}

Fixed version (ground truth):
public void input(final ByteBuffer input){
  TransportResult frameParsingError=null;
  int size=_size;
  ByteBuffer nextFramesInput=null;
  byte[] header=new byte[8];
  boolean transportAccepting=true;
  ByteBuffer currentInput=input;
  while (currentInput.hasRemaining() && _state != State.ERROR && transportAccepting) {
switch (_state) {
case HEADER0:
      if (currentInput.hasRemaining()) {
        byte c=currentInput.get();
        header[0]=c;
        _state=State.HEADER1;
      }
 else {
        break;
      }
case HEADER1:
    if (currentInput.hasRemaining()) {
      byte c=currentInput.get();
      header[1]=c;
      _state=State.HEADER2;
    }
 else {
      break;
    }
case HEADER2:
  if (currentInput.hasRemaining()) {
    byte c=currentInput.get();
    header[2]=c;
    _state=State.HEADER3;
  }
 else {
    break;
  }
case HEADER3:
if (currentInput.hasRemaining()) {
  byte c=currentInput.get();
  header[3]=c;
  _state=State.HEADER4;
}
 else {
  break;
}
case HEADER4:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[4]=c;
_state=State.HEADER5;
}
 else {
break;
}
case HEADER5:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[5]=c;
_state=State.HEADER6;
}
 else {
break;
}
case HEADER6:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[6]=c;
_state=State.HEADER7;
}
 else {
break;
}
case HEADER7:
if (currentInput.hasRemaining()) {
byte c=currentInput.get();
header[7]=c;
_peer.receiveHeader(header);
_state=State.SIZE_0;
}
 else {
break;
}
case SIZE_0:
if (!currentInput.hasRemaining()) {
break;
}
if (currentInput.remaining() >= 4) {
size=currentInput.getInt();
_state=State.PRE_PARSE;
break;
}
 else {
size=(currentInput.get() << 24) & 0xFF000000;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_1;
break;
}
}
case SIZE_1:
size|=(currentInput.get() << 16) & 0xFF0000;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_2;
break;
}
case SIZE_2:
size|=(currentInput.get() << 8) & 0xFF00;
if (!currentInput.hasRemaining()) {
_state=State.SIZE_3;
break;
}
case SIZE_3:
size|=currentInput.get() & 0xFF;
_state=State.PRE_PARSE;
case PRE_PARSE:
;
if (size < 8) {
frameParsingError=error("String_Node_Str" + "String_Node_Str",_size,8);
_state=State.ERROR;
break;
}
if (currentInput.remaining() < size - 4) {
_frameBuffer=ByteBuffer.allocate(size - 4);
_frameBuffer.put(currentInput);
_state=State.BUFFERING;
break;
}
case BUFFERING:
if (_frameBuffer != null) {
if (currentInput.remaining() < _frameBuffer.remaining()) {
_frameBuffer.put(currentInput);
break;
}
 else {
ByteBuffer dup=currentInput.duplicate();
dup.limit(dup.position() + _frameBuffer.remaining());
currentInput.position(currentInput.position() + _frameBuffer.remaining());
_frameBuffer.put(dup);
nextFramesInput=currentInput;
_frameBuffer.flip();
currentInput=_frameBuffer;
_state=State.PARSING;
}
}
case PARSING:
int dataOffset=(currentInput.get() << 2) & 0x3FF;
if (dataOffset < 8) {
frameParsingError=error("String_Node_Str",dataOffset,8);
_state=State.ERROR;
break;
}
 else if (dataOffset > size) {
frameParsingError=error("String_Node_Str",dataOffset,_size);
_state=State.ERROR;
break;
}
int type=currentInput.get() & 0xFF;
int channel=currentInput.getShort() & 0xFFFF;
if (dataOffset != 8) {
currentInput.position(currentInput.position() + dataOffset - 8);
}
final int frameBodySize=size - dataOffset;
if (nextFramesInput == null) {
nextFramesInput=currentInput;
currentInput=currentInput.duplicate();
final int endPos=currentInput.position() + frameBodySize;
currentInput.limit(endPos);
nextFramesInput.position(endPos);
}
try {
if (frameBodySize > 0) {
Data data=Data.Factory.create();
data.decode(currentInput);
Data.DataType dataType=data.type();
if (dataType != Data.DataType.DESCRIBED) {
throw new IllegalArgumentException("String_Node_Str" + Data.DataType.DESCRIBED + "String_Node_Str"+ dataType);
}
DescribedType describedType=data.getDescribedType();
LOGGER.debug("String_Node_Str",describedType);
Binary payload;
if (currentInput.hasRemaining()) {
byte[] payloadBytes=new byte[currentInput.remaining()];
currentInput.get(payloadBytes);
payload=new Binary(payloadBytes);
}
 else {
payload=null;
}
_peer.receiveFrame(type,channel,describedType,payload);
}
 else {
LOGGER.debug("String_Node_Str");
}
_size=0;
currentInput=nextFramesInput;
nextFramesInput=null;
_frameBuffer=null;
if (_state != State.HEADER0) {
_state=State.SIZE_0;
}
}
 catch (DecodeException ex) {
_state=State.ERROR;
frameParsingError=error(ex);
}
break;
case ERROR:
}
}
_size=size;
if (_state == State.ERROR) {
if (frameParsingError != null) {
frameParsingError.checkIsOk();
}
 else {
TransportResultFactory.error("String_Node_Str").checkIsOk();
}
}
}