Repository navigation
Fix iterator early exit leak - #427
Merged
Merged
Conversation
ucl_object_iterate with expand_values on a UCL_OBJECT allocates a heap iterator that is freed only when the iteration reaches the end. The 19 loops in ucl_schema.c and the UCL_OBJECT case of ucl_object_compare stop early - 'while (ret && ...)' after a failed check, or break on a difference - and each such exit leaks the iterator. That is every failed ucl_object_validate against an object schema, and every ucl_object_compare of two equal-size objects that differ. It is also why test_schema reports leaks under LeakSanitizer: apart from one in the test program itself, they are these iterators. Call ucl_object_iterate_end after each loop. It is a no-op when the iteration completed and for arrays, so it is safe on every path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W3aXdPKAnVwjiNtZstnmPj
vstakhov
approved these changes
Oct 7, 2026
vstakhov
left a comment
Owner
There was a problem hiding this comment.
LGTM. On master, leaks shows the ucl_hash_iterate2 iterators leaking on every failed schema validation (test_schema: 1-26 leaks per suite). With this PR only the test harness's own stdin buffer remains. Checked that every added call follows an expand_values=true loop, so it doesn't depend on #425.
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.
Fix #426