Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ private int generateHeadersFrame(ByteBufferPool.Accumulator accumulator, long st
int maxHeaderLength = frameTypeLength + VarLenInt.MAX_LENGTH;
// The capacity of the buffer is larger than maxLength, but we need to enforce at most maxLength.
int maxLength = encoder.getMaxHeadersSize();

// Acquire buffer and immediately append to the accumulator so that it is released if a failure occurs.
RetainableByteBuffer buffer = getByteBufferPool().acquire(maxHeaderLength + maxLength, useDirectByteBuffers);
accumulator.append(buffer);

ByteBuffer byteBuffer = buffer.getByteBuffer();
BufferUtil.clearToFill(byteBuffer);
byteBuffer.position(maxHeaderLength);
Expand All @@ -70,7 +74,6 @@ private int generateHeadersFrame(ByteBufferPool.Accumulator accumulator, long st
VarLenInt.encode(byteBuffer, FrameType.HEADERS.type());
VarLenInt.encode(byteBuffer, dataLength);
byteBuffer.position(position);
accumulator.append(buffer);
return headerLength + dataLength;
}
catch (QpackException x)
Expand Down