Skip to content

Commit

Permalink
#10226 fix buffer leak in consumeAvailable() when HttpStream.consumeA…
Browse files Browse the repository at this point in the history
…vailable() leaves unconsumed content

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Aug 30, 2023
1 parent 87430f9 commit 58a5499
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1145,11 +1145,18 @@ public Throwable consumeAvailable()
{
Throwable result = HttpStream.consumeAvailable(this, getHttpConfiguration());
if (result != null)
{
_generator.setPersistent(false);
// If the parser is not at the end, an idle timeout occurred and nothing
// is ever going to release the buffer -> release it here.
if (!_parser.isState(HttpParser.State.END))
releaseRequestBuffer();
// If HttpStream.consumeAvailable() returns an error, there may be unconsumed content left,
// so we must make sure the buffer is released and that the next chunk indicates the end of the stream.
if (_retainableByteBuffer != null)
{
_retainableByteBuffer.release();
_retainableByteBuffer = null;
}
if (_chunk == null)
_chunk = Content.Chunk.from(result, true);
}
return result;
}

Expand Down

0 comments on commit 58a5499

Please sign in to comment.