diff options
author | Camille Mohr-Daurat <pouleyKetchoup@gmail.com> | 2021-10-27 12:40:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-27 12:40:50 -0700 |
commit | 3c527dcbbdaa6a92b00c3ccd44c22347f1d3c5bc (patch) | |
tree | 66951d5d64ff8f21f6a26004e5336802a4ce20c4 | |
parent | 21529c90f89c8f045851fa678aaaf67a9b7bbb3a (diff) | |
parent | 258b5d001968aea99d2d7a2eea98a8032da34349 (diff) |
Merge pull request #54157 from bjauny/fix_potential_nullpointer_collision3d
Fix potential null pointer use, based on #54094 fix
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 4 | ||||
-rw-r--r-- | scene/3d/collision_object_3d.cpp | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 28facd09ce..4b348f12e6 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -50,7 +50,9 @@ void CollisionObject2D::_notification(int p_what) { } if (!disabled || (disable_mode != DISABLE_MODE_REMOVE)) { - RID space = get_world_2d()->get_space(); + Ref<World2D> world_ref = get_world_2d(); + ERR_FAIL_COND(!world_ref.is_valid()); + RID space = world_ref->get_space(); if (area) { PhysicsServer2D::get_singleton()->area_set_space(rid, space); } else { diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index fd891a5e13..a166a05c71 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -64,7 +64,9 @@ void CollisionObject3D::_notification(int p_what) { } if (!disabled || (disable_mode != DISABLE_MODE_REMOVE)) { - RID space = get_world_3d()->get_space(); + Ref<World3D> world_ref = get_world_3d(); + ERR_FAIL_COND(!world_ref.is_valid()); + RID space = world_ref->get_space(); if (area) { PhysicsServer3D::get_singleton()->area_set_space(rid, space); } else { |