From 69cf996ce60f9419922b0de4590b7ece7fa0a8be Mon Sep 17 00:00:00 2001 From: UsernameIsAReservedWord Date: Thu, 26 Feb 2015 19:27:32 +0100 Subject: [PATCH] should fixes #1284 I could reproduce the crash described in #1284 only with 32bits versions of godot. The test scene contains a Plane collision shape, and a kinematicsbody with a Sphere collision shape. The crash occurs into `CollisionSolverSW::solve_distance_plane()` on line 299 when `p_shape_A` is a `PlaneShapeSW` object and when `p_shape_B` is a `MotionShapeSW` object, because `int support_count;` is not initialized by default, and because `MotionShapeSW::get_supports()` does not change `support_count` once passed as referenced parameter, and if the default value of `support_count` is greater than the length of `supports[16]`. I don't know if it is the good way to fix it because i'm not skilled ennough with the physics server inner working, but this fix prevents the crash and the test-scene seems to work correctly. --- servers/physics/shape_sw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index cdb21556b83..bcf8fbdc8d3 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -438,7 +438,7 @@ struct MotionShapeSW : public ShapeSW { } return support; } - virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const {} + virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const { r_amount=0; } bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const { return false; } Vector3 get_moment_of_inertia(float p_mass) const { return Vector3(); }