Skip to content

Fix memory leak due to missing compressor close in the LengthPrependerAndCompressor #3786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025
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 @@ -114,6 +114,16 @@ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)
}
}

@Override
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
{
if ( zlib != null )
{
zlib.free();
zlib = null;
}
}

public void setCompose(boolean compose)
{
if ( compose )
Expand Down Expand Up @@ -147,6 +157,7 @@ public void setCompress(boolean compress)
if ( zlib != null )
{
zlib.free();
zlib = null;
}
}
}
Expand Down Expand Up @@ -180,10 +191,6 @@ private static byte varintSize(int value)
{
return 4;
}
if ( MAX_SUPPORTED_VARINT_LENGTH_LEN < 5 )
{
throw new IllegalArgumentException( "Packet length " + value + " longer than supported (max. 268435455 for 4 byte varint)" );
}
return 5;
throw new IllegalArgumentException( "Packet length " + value + " longer than supported (max. 268435455 for 4 byte varint)" );
}
}