Fix memory leak and dead code in get_structure_callback#54
Open
iliaal wants to merge 1 commit into
Open
Conversation
The callback emalloc'd a fixed 1KB buffer for every part and, on the "too many sections" path, returned FAILURE without freeing it. That grow-and-bail logic was also dead code: erealloc aborts rather than returning NULL, and the size check could only fire after the doubling realloc had already grown the buffer. Replace the manual buffer with a smart_string that grows as needed and is always released. The output (dot-joined section ids) is unchanged.
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.
get_structure_callbackemalloc'd a fixed 1KB buffer per part and, on the "too many sections" path, returned FAILURE without freeing it. The grow-and-bail block was also dead code:ereallocaborts rather than returning NULL, and the size check could only fire after the doubling realloc had already grown the buffer.Replaced the manual buffer with a
smart_stringthat grows on demand and is always freed. The output (dot-joined section ids) is unchanged.