printer cbor BUGFIX crash when printing (leaf-)lists nested in a list - #2557
Merged
michalvasko merged 1 commit intoAug 18, 2026
Merged
Conversation
The CBOR printer kept a single "currently open array" pointer (cborpr_ctx.array) shared across all nesting levels, while tracking the open nodes on a proper stack (cborpr_ctx.open). When a leaf-list or list was nested inside a list, printing the inner array overwrote that pointer and then reset it to NULL, so the enclosing list subsequently pushed into a NULL array, causing a segfault in cbor_array_push(). Replace the single array pointer with a stack (cborpr_ctx.arrays) kept parallel to the open-node stack, add cbor_current_array() to fetch the innermost open array, and update cbor_print_leaf_list()/cbor_print_opaq() and their callers accordingly. The stack is freed on all exit paths of cbor_print_data(). Add a regression test (test_nested_list) covering a leaf-list nested in a list, a list nested in a list, and mixed multi-instance nesting, plus the supporting list-nested node in the cbor-test module. Co-authored-by: Cursor <cursoragent@cursor.com>
michalvasko
approved these changes
Aug 18, 2026
Member
|
Thanks, looks fine. |
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.
The CBOR printer kept a single "currently open array" pointer (cborpr_ctx.array) shared across all nesting levels, while tracking the open nodes on a proper stack (cborpr_ctx.open). When a leaf-list or list was nested inside a list, printing the inner array overwrote that pointer and then reset it to NULL, so the enclosing list subsequently pushed into a NULL array, causing a segfault in cbor_array_push().
Replace the single array pointer with a stack (cborpr_ctx.arrays) kept parallel to the open-node stack, add cbor_current_array() to fetch the innermost open array, and update cbor_print_leaf_list()/cbor_print_opaq() and their callers accordingly. The stack is freed on all exit paths of cbor_print_data().
Add a regression test (test_nested_list) covering a leaf-list nested in a list, a list nested in a list, and mixed multi-instance nesting, plus the supporting list-nested node in the cbor-test module.