Skip to content

Commit

Permalink
#10226 - fix GZIPContentDecoder buffer leak of zero-capacity buffers
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban authored and olamy committed Aug 24, 2023
1 parent 997c949 commit e07db72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ private enum State
*/
public RetainableByteBuffer acquire(int capacity)
{
// Zero-capacity buffers aren't released, they MUST NOT come from the pool.
if (capacity == 0)
return RetainableByteBuffer.EMPTY;
return _pool.acquire(capacity, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
*/
public interface RetainableByteBuffer extends Retainable
{
/**
* A Zero-capacity, non-retainable {@code RetainableByteBuffer}.
*/
public static RetainableByteBuffer EMPTY = wrap(BufferUtil.EMPTY_BUFFER);

/**
* <p>Returns a non-retainable {@code RetainableByteBuffer} that wraps
* the given {@code ByteBuffer}.</p>
Expand Down

0 comments on commit e07db72

Please sign in to comment.