From d2aa3031dc65b1e43337c03194c2d4ee69c8a67e Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Mon, 22 Jun 2020 10:22:11 +0200 Subject: [PATCH] Fix crashes with invalid shapes in BulletPhysicsDirectSpaceState queries (cherry picked from commit 8b0232bf295c924c157b30f78c9b991fb211dd73) --- modules/bullet/space_bullet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 1c5dee47f6f..e27415ccd79 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -123,6 +123,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra return 0; ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ERR_FAIL_COND_V(!shape, 0); btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) { @@ -163,6 +164,7 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf return false; ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ERR_FAIL_COND_V(!shape, false); btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin); if (!btShape->isConvex()) { @@ -215,6 +217,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & return 0; ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ERR_FAIL_COND_V(!shape, false); btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) { @@ -247,6 +250,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); + ERR_FAIL_COND_V(!shape, false); btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin); if (!btShape->isConvex()) {