-
Notifications
You must be signed in to change notification settings - Fork 29
fix: memory leak #75
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
fix: memory leak #75
Conversation
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes revise memory management in brotli.c by removing redundant free/release calls for zend_string objects, simplifying buffer cleanup, adding early returns on allocation or read failures, and ensuring context cleanup on compression errors. No exported or public entity declarations were altered. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant brotli_compress
participant php_brotli_context_close
User->>brotli_compress: Request compression
brotli_compress->>brotli_compress: Allocate resources
alt Compression fails
brotli_compress->>php_brotli_context_close: Cleanup context
brotli_compress-->>User: Return FALSE
else Compression succeeds
brotli_compress-->>User: Return compressed data
end
Possibly related PRs
Poem
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
brotli.c
(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: ci (8.4-zts-alpine, apcu, php, linux/amd64)
- GitHub Check: ci (8.2, x64, ts, vs16, true)
- GitHub Check: ci (8.3-alpine, php, linux/amd64)
- GitHub Check: ci (8.1-zts-alpine, php, linux/amd64)
- GitHub Check: ci (8.1-alpine, system, php, linux/amd64)
- GitHub Check: ci (8.3-zts-alpine, apcu, php, linux/amd64)
- GitHub Check: ci (8.2-zts-alpine, system, apcu, php, linux/amd64)
- GitHub Check: ci (8.3-alpine, apcu, php, linux/amd64)
- GitHub Check: ci (8.2-alpine, apcu, php, linux/386)
- GitHub Check: ci (8.2, x64, ts, vs16, false)
- GitHub Check: ci (7.2-alpine, ghcr.io/kjdev/php, linux/amd64)
- GitHub Check: ci (8.1, x86, ts, vs16, true)
- GitHub Check: ci (8.1, x64, ts, vs16, true)
- GitHub Check: ci (8.2-alpine, php, linux/amd64)
- GitHub Check: ci (8.2, x64, nts, vs16, false)
- GitHub Check: ci (8.3, x64, ts, vs16, true)
- GitHub Check: ci (8.1, x86, ts, vs16, false)
- GitHub Check: ci (8.3, x86, nts, vs16, true)
- GitHub Check: ci (8.3, x64, nts, vs16, true)
- GitHub Check: ci (8.4, x86, nts, vs17, true)
🔇 Additional comments (4)
brotli.c (4)
473-478
: Possiblezend_string
ownership leak – verify lifecycle.
dict
is now passed straight through tophp_brotli_context_create_encoder_ex()
and never released.
IfBrotliEncoderPrepareDictionary()
copies the buffer this is fine, otherwise thezend_string
will leak (previous code released it).Please double-check the encoder implementation and either keep the release or document why the leak is acceptable.
823-824
: No functional change – benign.
894-895
: Good cleanup simplification.Unconditional frees mean fewer branches and no leaks here – nice.
1520-1521
: Correctly closing context on error – good catch.Adding
php_brotli_context_close(&ctx)
prevents the encoder state from leaking on the failure path.
Summary by CodeRabbit