Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix physics platform behaviour regression #97315

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scene/3d/physics/character_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ bool CharacterBody3D::move_and_slide() {

// We need to check the platform_rid object still exists before accessing.
// A valid RID is no guarantee that the object has not been deleted.
if (ObjectDB::get_instance(platform_object_id)) {
//this approach makes sure there is less delay between the actual body velocity and the one we saved

// We can only perform the ObjectDB lifetime check on Object derived objects.
// Note that physics also creates RIDs for non-Object derived objects, these cannot
// be lifetime checked through ObjectDB, and therefore there is a still a vulnerability
// to dangling RIDs (access after free) in this scenario.
if (platform_object_id.is_null() || ObjectDB::get_instance(platform_object_id)) {
// This approach makes sure there is less delay between the actual body velocity and the one we saved.
bs = PhysicsServer3D::get_singleton()->body_get_direct_state(platform_rid);
}

Expand Down
Loading