mbstring: Fix memory leak in mail header parsing#22254
Open
iliaal wants to merge 1 commit into
Open
Conversation
Contributor
|
@iliaal Thanks for discovering this issue! It looks to me like this could be written more concisely in the form: Am I missing something? |
Contributor
|
@iliaal To avoid unnecessary back-and-forth, please make sure that your code matches the style of the surrounding code. |
A header field name with no value (input ending at the colon) leaves fld_name allocated but unreleased, since the cleanup blocks only fire when both fld_name and fld_val are set. Release the dangling fld_name in both the loop-body and end-of-input branches.
76141ea to
8f1b7c2
Compare
Contributor
Author
|
Right, that's cleaner and drops the duplicated release. Reworked both blocks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A mail header consisting of a field name with no value (the input ends right after the colon) leaves the fld_name zend_string allocated but never released, because the cleanup only runs when both fld_name and fld_val are set. Reproduces via mb_send_mail() with a header like "X-Leak:". It is released in both the loop-body and end-of-input branches.