Skip to content

fix(tombmap): prevent dangling pointer in Mut wrapper#351

Merged
JeanMertz merged 1 commit intomainfrom
jean/pr40
Dec 30, 2025
Merged

fix(tombmap): prevent dangling pointer in Mut wrapper#351
JeanMertz merged 1 commit intomainfrom
jean/pr40

Conversation

@JeanMertz
Copy link
Collaborator

@JeanMertz JeanMertz commented Dec 30, 2025

The Mut::new_untracked constructor was previously creating a ptr::NonNull from a temporary HashSet created on the stack. This resulted in a dangling pointer that would cause undefined behavior when accessed during dereferencing or when calling get_mut.

The modified field in Mut is now an Option. When created via Mut::new_untracked, it is set to None, and modification tracking is skipped. IterMut continues to provide the pointer to its internal tracking set to ensure that modifications via iterator are still correctly captured.

The `Mut::new` constructor was previously creating a `ptr::NonNull` from
a temporary `HashSet` created on the stack. This resulted in a dangling
pointer that would cause undefined behavior when accessed during
dereferencing or when calling `get_mut`.

The `modified` field in `Mut` is now an `Option`. When created via
`Mut::new`, it is set to `None`, and modification tracking is skipped.
`IterMut` continues to provide the pointer to its internal tracking set
to ensure that modifications via iterator are still correctly captured.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit 587595f into main Dec 30, 2025
10 checks passed
@JeanMertz JeanMertz deleted the jean/pr40 branch December 30, 2025 16:34
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.

1 participant