Repository navigation
Conversation
Clean up the installed readers in do_init_reader_stack() if adding the CRLF reader fails. Let Curl_creader_set() rely on that cleanup instead of freeing the client reader separately. Add unit3307 to enable allocation failure from the reader length callback and verify cleanup without depending on allocation ordinals.
There was a problem hiding this comment.
🟢 Approval recommended
Cleanup ownership is consistent, and the regression test checks the failure result, empty stack, and exactly-once reader closure.
No open issues 🎉
What changed in this PR
This PR fixes reader-stack cleanup when CRLF line-conversion setup fails, preventing freed readers from remaining reachable.
Changes:
- Reset the reader stack on line-conversion setup failure and remove redundant cleanup from
Curl_creader_set(). - Add a regression test that triggers allocation failure from the reader length callback and checks an empty stack and exactly-once closure.
- Register the test with the unit-test build and test runner.
| File | Description |
|---|---|
| tests/unit/unit3307.c | Tests reader cleanup after line-conversion allocation failure. |
| tests/unit/Makefile.inc | Registers the new unit-test source. |
| tests/data/test3307 | Defines the test and its memory-tracking requirements. |
| tests/data/Makefile.am | Registers the test data file. |
| lib/sendf.c | Centralizes failure cleanup in reader-stack initialization. |
Review effort: Balanced
icing
approved these changes
Oct 26, 2026
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.
Clean up the installed readers in do_init_reader_stack() if adding the CRLF reader fails. Let Curl_creader_set() rely on that cleanup instead of freeing the client reader separately.
Add unit3307 to enable allocation failure from the reader length callback and verify cleanup without depending on allocation ordinals.