KEMBAR78
Fix use-after-free in json_validator sample by riverar · Pull Request #3668 · microsoft/windows-rs · GitHub
Skip to content

Conversation

@riverar
Copy link
Collaborator

@riverar riverar commented Jul 16, 2025

String::from_utf8_lossy returns a Cow<'_, str> that references the original memory when the input is considered valid UTF-8. Calling .into_owned() forces allocation of an owned String, allowing us to safely free the FFI memory with CoTaskMemFree.

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted!

@kennykerr kennykerr merged commit 99208c8 into master Jul 17, 2025
29 checks passed
@kennykerr kennykerr deleted the rafael/fix-json-sample branch July 17, 2025 17:59
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