Skip to content

Fix/trie ref long node key and empty is shared - #145

Merged
luketpeterson merged 4 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-long-node-key-and-empty-is-shared
Oct 2, 2026
Merged

luketpeterson merged 4 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/trie-ref-long-node-key-and-empty-is-shared

Conversation

@imlvts

@imlvts imlvts commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Fix TrieRef lookups with a node key longer than its buffer
new_with_key_and_path_in copied the focus's node key into a fixed stack
buffer, overflowing it (UB in release) when the key was longer, and
truncated key + path when the two together didn't fit. No child key is
longer than a node key, so only the first MAX_NODE_KEY_BYTES bytes of the
combined key can decide a step: look up that prefix, and keep stepping
through a child that begins within the node key. A combined key too long
to remain at a node is invalid.

(similar to Luke's 203b7d5))

Fix TrieRef::is_shared on an empty node

imlvts and others added 4 commits September 29, 2026 19:58
new_with_key_and_path_in copied the focus's node key into a fixed stack
buffer, overflowing it (UB in release) when the key was longer, and
truncated key + path when the two together didn't fit. No child key is
longer than a node key, so only the first MAX_NODE_KEY_BYTES bytes of the
combined key can decide a step: look up that prefix, and keep stepping
through a child that begins within the node key. A combined key too long
to remain at a node is invalid.
@luketpeterson

Copy link
Copy Markdown
Collaborator

Good fixes. I added some optimizations on top. Merging.

@luketpeterson
luketpeterson merged commit 3096590 into Adam-Vandervorst:master Oct 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants