Skip to content

Release source critical array before throwing OOM in LZ4JNI - #124

Merged
yawkat merged 1 commit into
mainfrom
fix/issue-83
Sep 25, 2026
Merged

yawkat merged 1 commit into
mainfrom
fix/issue-83

Conversation

@yawkat

@yawkat yawkat commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Fixes #83.

In LZ4_compress_limitedOutput, LZ4_compressHC, LZ4_decompress_fast and LZ4_decompress_safe, the out == NULL branch now releases the source critical array before calling throw_OOM. The _fastReset functions already did this. Before, this path leaked the source critical array and called ThrowNew inside a critical region.

The branch isn't reachable in a unit test, because HotSpot pins arrays and doesn't fail GetPrimitiveArrayCritical. Instead, LZ4Test, LZ4FastResetTest and LZ4FactoryTest were run against the rebuilt native library to check that the normal path still works. All passed.

🤖 Generated with Claude Code

LZ4_compress_limitedOutput, LZ4_compressHC, LZ4_decompress_fast and
LZ4_decompress_safe returned without releasing the source array when
acquiring the destination failed, and threw the OutOfMemoryError from
inside the critical region. Release the source first, as the
_fastReset variants already do.

Fixes #83

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yawkat
yawkat enabled auto-merge (squash) September 25, 2026 15:32
@yawkat yawkat added this to the 1.11.4 milestone Sep 25, 2026
@yawkat
yawkat merged commit 02752a3 into main Sep 25, 2026
6 checks passed
@yawkat
yawkat deleted the fix/issue-83 branch September 25, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LZ4JNI array methods leak the source critical array and throw from inside a critical region

1 participant