Skip to content

Avoid use-after-free with overlay keys - #188

Merged
vilhalmer merged 1 commit into
GodotVR:masterfrom
liminetics:fix-use-after-free
Jul 30, 2026
Merged

vilhalmer merged 1 commit into
GodotVR:masterfrom
liminetics:fix-use-after-free

Conversation

@vilhalmer

Copy link
Copy Markdown
Collaborator

The design of Godot's CharString class means that it is unsafe to store the result of the expression .utf8().get_data(), as the intermediate CharString is discarded and the char* is then pointing at garbage data. Using the expression fully inline is safe, as the memory survives until after we return from passing it to OpenVR.

Going to look into whether its possible to create a linter rule to prevent this in the future.

The design of Godot's CharString class means that it is unsafe to store
the result of the expression `.utf8().get_data()`, as the intermediate
CharString is discarded and the char* is then pointing at garbage data.
Using the expression fully inline is safe, as the memory survives until
after we return from passing it to OpenVR.
@vilhalmer

Copy link
Copy Markdown
Collaborator Author

cc @dfgHiatus, you'll probably want to cherry-pick this to the Babble overlay.

@vilhalmer
vilhalmer merged commit e0926c5 into GodotVR:master Jul 30, 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.

1 participant