Fix memory leak of parameter name after an RFC2231 parameter#61
Open
iliaal wants to merge 1 commit into
Open
Conversation
currentencoded was set to 1 on the first RFC2231 (name*N) parameter and never reset, so every later parameter took the is_rfc2231_name finalize path. When a later plain parameter arrived, neither the !currentencoded branch (stale 1) nor the namechanged branch (stale 0) consumed its name, so the emalloc'd name was neither stored nor freed. A header such as "Content-Type: x/y; a*0=\"foo\"; b=\"bar\"" leaked one allocation per plain-after-encoded parameter. Reset currentencoded per parameter so it reflects the current parameter only; the plain parameter now takes the !currentencoded branch, which stores and frees its name.
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.
currentencoded was set to 1 on the first RFC2231 (name*N) parameter and never reset, so every later parameter took the is_rfc2231_name finalize branch. When a later plain parameter arrived, neither the !currentencoded branch (stale 1) nor the namechanged branch (stale 0) consumed it, so the recombined parameter name was neither stored nor freed. Resetting currentencoded per parameter routes the plain parameter back through the normal path, which stores and frees it.
Reproducer: parsing Content-Type: x/y; a*0="foo"; b="bar" leaks one allocation per plain parameter that follows an encoded one.