Skip to content

Commit 52076f2

Browse files
committed
Fix ByteBuf memory leak in blob deserialization error paths
When CRC validation fails during blob deserialization in MessageFormatRecord, the ByteBuf allocated by Utils.readNettyByteBufFromCrcInputStream() was not being released, causing a memory leak. The issue affected all three blob format versions (V1, V2, V3) in their respective deserializeBlobRecord() methods. When corrupt data triggered a MessageFormatException during CRC validation, the allocated ByteBuf slice remained unreleased. Changes: - Extract CRC validation logic into validateCrcAndManageByteBuf() helper method - Implement try-finally pattern to ensure ByteBuf.release() on validation failure - Apply fix consistently across Blob_Format_V1, V2, and V3 deserializers - Add comprehensive leak detection tests using custom ByteBuf wrappers Tests: - MessageFormatCorruptDataLeakTest verifies ByteBuf cleanup on corrupt data - Parameterized tests cover all blob format versions (V1, V2, V3) - Control tests ensure no false positives on successful deserialization - Uses SliceCapturingByteBuf wrapper via DelegateByteBuf to track slice creation
1 parent ace4356 commit 52076f2

File tree

3 files changed

+1196
-18
lines changed

3 files changed

+1196
-18
lines changed

0 commit comments

Comments
 (0)