Skip to content

fix: copy table keys into merged pool in toml_merge#37

Merged
cktan merged 1 commit into
cktan:mainfrom
dutow:fix/merge-key-dangling-pointer
Jun 18, 2026
Merged

fix: copy table keys into merged pool in toml_merge#37
cktan merged 1 commit into
cktan:mainfrom
dutow:fix/merge-key-dangling-pointer

Conversation

@dutow

@dutow dutow commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

tab_emplace stores key pointers without copying, so datum_copy and datum_merge aliased the merged tree's keys into the source pools. Freeing an input after merge dangled those keys -> use-after-free.

Copy each key into the merged pool, like string values already are. Pool size (r1->top + r2->top) stays a valid upper bound.

Adds test_keys_outlive_inputs: aborts under ASan without the fix.

tab_emplace stores key pointers without copying, so datum_copy and
datum_merge aliased the merged tree's keys into the source pools.
Freeing an input after merge dangled those keys -> use-after-free.

Copy each key into the merged pool, like string values already are.
Pool size (r1->top + r2->top) stays a valid upper bound.

Adds test_keys_outlive_inputs: aborts under ASan without the fix.
@dutow dutow force-pushed the fix/merge-key-dangling-pointer branch from 2e66a65 to 4181f98 Compare June 17, 2026 15:46
@cktan cktan merged commit 173a5fb into cktan:main Jun 18, 2026
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