Skip to content

Conversation

@Watson1978
Copy link
Contributor

This PR fixes a memory leak when an invalid level option is passed to Zstd.compress.

If non-Integer object was given as compression level, NUM2INT cause a TypeError exception and memory leak.

This changes will release the context if necessary and raise an exception if non-Integer object was given as compression level.

Reproduce

require 'zstd-ruby'

10000.times { Zstd.compress("abc", level: "xxx") rescue nil }

This PR fixes a memory leak when an invalid level option is passed to Zstd.compress.

If non-Integer object was given as compression level,
NUM2INT cause a TypeError exception and memory leak.

This changes will release the context if necessary and raise an exception
if non-Integer object was given as compression level.
@SpringMT
Copy link
Owner

🙇 👍 Thank you!

@SpringMT SpringMT merged commit a536da8 into SpringMT:main Dec 23, 2025
7 checks passed
@Watson1978 Watson1978 deleted the fix-leak3 branch December 23, 2025 15:28
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.

2 participants