Program: 107649
Project: 107649
Buggy source:
protected int doProcess(Buffer inBuffer,Buffer outBuffer){
  byte[] in=(byte[])inBuffer.getData();
  int inOffset=inBuffer.getOffset();
  int inLength=inBuffer.getLength();
  short[] out=validateShortArraySize(outBuffer,frameLength);
  int outOffset=0;
  boolean decodeFEC=false;
  long seqNo=inBuffer.getSequenceNumber();
  int nbPacketsLost=0;
  if ((lastSeqNo != Buffer.SEQUENCE_UNKNOWN) && (seqNo != lastSeqNo) && (seqNo != lastSeqNo + 1)&& (seqNo > lastSeqNo)) {
    decodeFEC=true;
    nbPacketsLost=(int)(seqNo - lastSeqNo - 1);
  }
  if ((inBuffer.getFlags() & Buffer.FLAG_SKIP_FEC) != 0) {
    decodeFEC=false;
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + seqNo + "String_Node_Str");
    }
  }
  int lostFlag=0;
  if (decodeFEC) {
    lbrrBytes[0]=0;
    DecAPI.SKP_Silk_SDK_search_for_LBRR(in,inOffset,(short)inLength,nbPacketsLost,lbrrData,0,lbrrBytes);
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + lastSeqNo + "String_Node_Str"+ seqNo);
      logger.trace("String_Node_Str" + lbrrBytes[0] + "String_Node_Str");
    }
    outputLength[0]=frameLength;
    if (lbrrBytes[0] == 0) {
      lostFlag=1;
    }
 else     if (DecAPI.SKP_Silk_SDK_Decode(decState,decControl,0,lbrrData,0,lbrrBytes[0],out,outOffset,outputLength) == 0) {
      nbFECDecoded++;
      outBuffer.setDuration(FRAME_DURATION * 1000000);
      outBuffer.setLength(outputLength[0]);
      outBuffer.setOffset(outOffset);
      outBuffer.setFlags(outBuffer.getFlags() | BUFFER_FLAG_FEC);
      outBuffer.setFlags(outBuffer.getFlags() & ~BUFFER_FLAG_PLC);
      lastSeqNo++;
      if (lastSeqNo > 65535)       lastSeqNo=0;
      return INPUT_BUFFER_NOT_CONSUMED;
    }
 else {
      nbFECNotDecoded++;
      if (nbPacketsLost > 0)       this.nbPacketsLost+=nbPacketsLost;
      lastSeqNo=seqNo;
      return BUFFER_PROCESSED_FAILED;
    }
  }
 else   if (nbPacketsLost > 0)   this.nbPacketsLost+=nbPacketsLost;
  int processed;
{
    outputLength[0]=frameLength;
    if (DecAPI.SKP_Silk_SDK_Decode(decState,decControl,lostFlag,in,inOffset,inLength,out,outOffset,outputLength) == 0) {
      outBuffer.setDuration(FRAME_DURATION * 1000000);
      outBuffer.setLength(outputLength[0]);
      outBuffer.setOffset(outOffset);
      if (lostFlag == 0) {
        outBuffer.setFlags(outBuffer.getFlags() & ~(BUFFER_FLAG_FEC | BUFFER_FLAG_PLC));
        if (decControl.moreInternalDecoderFrames == 0) {
          nbPacketsDecoded++;
          processed=BUFFER_PROCESSED_OK;
        }
 else {
          framesPerPayload++;
          if (framesPerPayload >= MAX_FRAMES_PER_PAYLOAD) {
            nbPacketsDecoded++;
            processed=BUFFER_PROCESSED_OK;
          }
 else           processed=INPUT_BUFFER_NOT_CONSUMED;
        }
        lastSeqNo=seqNo;
      }
 else {
        outBuffer.setFlags(outBuffer.getFlags() & ~BUFFER_FLAG_FEC);
        outBuffer.setFlags(outBuffer.getFlags() | BUFFER_FLAG_PLC);
        processed=INPUT_BUFFER_NOT_CONSUMED;
        lastSeqNo++;
        if (lastSeqNo > 65535)         lastSeqNo=0;
      }
    }
 else {
      processed=BUFFER_PROCESSED_FAILED;
      if (lostFlag == 1) {
        nbFECNotDecoded++;
        if (nbPacketsLost > 0)         this.nbPacketsLost+=nbPacketsLost;
      }
      lastSeqNo=seqNo;
    }
    if ((processed & INPUT_BUFFER_NOT_CONSUMED) != INPUT_BUFFER_NOT_CONSUMED)     framesPerPayload=0;
  }
  return processed;
}

Fixed version (ground truth):
protected int doProcess(Buffer inBuffer,Buffer outBuffer){
  byte[] in=(byte[])inBuffer.getData();
  int inOffset=inBuffer.getOffset();
  int inLength=inBuffer.getLength();
  short[] out=validateShortArraySize(outBuffer,frameLength);
  int outOffset=0;
  long seqNo=inBuffer.getSequenceNumber();
  int lostSeqNoCount=calculateLostSeqNoCount(lastSeqNo,seqNo);
  boolean decodeFEC=(lostSeqNoCount != 0);
  if ((inBuffer.getFlags() & Buffer.FLAG_SKIP_FEC) != 0) {
    decodeFEC=false;
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + seqNo + "String_Node_Str");
    }
  }
  int lostFlag=0;
  if (decodeFEC) {
    lbrrBytes[0]=0;
    DecAPI.SKP_Silk_SDK_search_for_LBRR(in,inOffset,(short)inLength,lostSeqNoCount,lbrrData,0,lbrrBytes);
    if (logger.isTraceEnabled()) {
      logger.trace("String_Node_Str" + lastSeqNo + "String_Node_Str"+ seqNo);
      logger.trace("String_Node_Str" + lbrrBytes[0] + "String_Node_Str");
    }
    outputLength[0]=frameLength;
    if (lbrrBytes[0] == 0) {
      lostFlag=1;
    }
 else     if (DecAPI.SKP_Silk_SDK_Decode(decState,decControl,0,lbrrData,0,lbrrBytes[0],out,outOffset,outputLength) == 0) {
      nbFECDecoded++;
      outBuffer.setDuration(FRAME_DURATION * 1000000);
      outBuffer.setLength(outputLength[0]);
      outBuffer.setOffset(outOffset);
      outBuffer.setFlags(outBuffer.getFlags() | BUFFER_FLAG_FEC);
      outBuffer.setFlags(outBuffer.getFlags() & ~BUFFER_FLAG_PLC);
      lastSeqNo=incrementSeqNo(lastSeqNo);
      return INPUT_BUFFER_NOT_CONSUMED;
    }
 else {
      nbFECNotDecoded++;
      if (lostSeqNoCount != 0)       this.nbPacketsLost+=lostSeqNoCount;
      lastSeqNo=seqNo;
      return BUFFER_PROCESSED_FAILED;
    }
  }
 else   if (lostSeqNoCount != 0)   this.nbPacketsLost+=lostSeqNoCount;
  int processed;
{
    outputLength[0]=frameLength;
    if (DecAPI.SKP_Silk_SDK_Decode(decState,decControl,lostFlag,in,inOffset,inLength,out,outOffset,outputLength) == 0) {
      outBuffer.setDuration(FRAME_DURATION * 1000000);
      outBuffer.setLength(outputLength[0]);
      outBuffer.setOffset(outOffset);
      if (lostFlag == 0) {
        outBuffer.setFlags(outBuffer.getFlags() & ~(BUFFER_FLAG_FEC | BUFFER_FLAG_PLC));
        if (decControl.moreInternalDecoderFrames == 0) {
          nbPacketsDecoded++;
          processed=BUFFER_PROCESSED_OK;
        }
 else {
          framesPerPayload++;
          if (framesPerPayload >= MAX_FRAMES_PER_PAYLOAD) {
            nbPacketsDecoded++;
            processed=BUFFER_PROCESSED_OK;
          }
 else           processed=INPUT_BUFFER_NOT_CONSUMED;
        }
        lastSeqNo=seqNo;
      }
 else {
        outBuffer.setFlags(outBuffer.getFlags() & ~BUFFER_FLAG_FEC);
        outBuffer.setFlags(outBuffer.getFlags() | BUFFER_FLAG_PLC);
        processed=INPUT_BUFFER_NOT_CONSUMED;
        lastSeqNo=incrementSeqNo(lastSeqNo);
      }
    }
 else {
      processed=BUFFER_PROCESSED_FAILED;
      if (lostFlag == 1) {
        nbFECNotDecoded++;
        if (lostSeqNoCount != 0)         this.nbPacketsLost+=lostSeqNoCount;
      }
      lastSeqNo=seqNo;
    }
    if ((processed & INPUT_BUFFER_NOT_CONSUMED) != INPUT_BUFFER_NOT_CONSUMED)     framesPerPayload=0;
  }
  return processed;
}