Program: 34737
Project: 34737
Buggy source:
/** 
 * @throws Exception
 * @see com.ibm.wsspi.genericbnf.BNFHeaders#marshallHeaders(WsByteBuffer[])
 */
@Override public WsByteBuffer[] marshallHeaders(WsByteBuffer[] src){
  final boolean bTrace=TraceComponent.isAnyTracingEnabled();
  if (bTrace && tc.isEntryEnabled()) {
    Tr.entry(tc,"String_Node_Str");
  }
  preMarshallHeaders();
  WsByteBuffer[] buffers=src;
  if (HeaderStorage.NOTSET != this.parseIndex && !overHeaderChangeLimit() && this.table == null) {
    buffers=marshallReuseHeaders(src);
  }
 else {
    if (null == buffers) {
      buffers=new WsByteBuffer[1];
      buffers[0]=allocateBuffer(this.outgoingHdrBufferSize);
      this.bytePosition=0;
    }
    HeaderElement elem=this.hdrSequence;
    for (; null != elem; elem=elem.nextSequence) {
      if (this.table != null) {
        try {
          buffers=encodeHeader(buffers,elem);
        }
 catch (        Exception e) {
          Tr.error(tc,e.getMessage());
          for (          WsByteBuffer buffer : buffers) {
            buffer.release();
            buffer=null;
          }
          return null;
        }
      }
 else {
        buffers=marshallHeader(buffers,elem);
      }
    }
    if (this.table == null) {
      buffers=putBytes(BNFHeaders.EOL,buffers);
    }
    buffers=flushCache(buffers);
    buffers[buffers.length - 1].flip();
  }
  postMarshallHeaders();
  if (bTrace && tc.isEntryEnabled()) {
    Tr.exit(tc,"String_Node_Str");
  }
  return buffers;
}

Fixed version (ground truth):
/** 
 * @throws Exception
 * @see com.ibm.wsspi.genericbnf.BNFHeaders#marshallHeaders(WsByteBuffer[])
 */
@Override public WsByteBuffer[] marshallHeaders(WsByteBuffer[] src){
  final boolean bTrace=TraceComponent.isAnyTracingEnabled();
  if (bTrace && tc.isEntryEnabled()) {
    Tr.entry(tc,"String_Node_Str");
  }
  preMarshallHeaders();
  WsByteBuffer[] buffers=src;
  if (HeaderStorage.NOTSET != this.parseIndex && !overHeaderChangeLimit() && this.table == null) {
    buffers=marshallReuseHeaders(src);
  }
 else {
    if (null == buffers) {
      buffers=new WsByteBuffer[1];
      buffers[0]=allocateBuffer(this.outgoingHdrBufferSize);
      this.bytePosition=0;
    }
    HeaderElement elem=this.hdrSequence;
    for (; null != elem; elem=elem.nextSequence) {
      if (this.table != null) {
        try {
          if (!H2Headers.checkIsValidH2WriteHeader(elem.getName())) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
              Tr.debug(tc,"String_Node_Str" + elem.getName());
            }
            continue;
          }
          buffers=encodeHeader(buffers,elem);
        }
 catch (        Exception e) {
          if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled()) {
            Tr.error(tc,e.getMessage());
          }
          for (          WsByteBuffer buffer : buffers) {
            buffer.release();
            buffer=null;
          }
          return null;
        }
      }
 else {
        buffers=marshallHeader(buffers,elem);
      }
    }
    if (this.table == null) {
      buffers=putBytes(BNFHeaders.EOL,buffers);
    }
    buffers=flushCache(buffers);
    buffers[buffers.length - 1].flip();
  }
  postMarshallHeaders();
  if (bTrace && tc.isEntryEnabled()) {
    Tr.exit(tc,"String_Node_Str");
  }
  return buffers;
}