From ebcff3b4a6e3762c508d9dc424036b947dae034f Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 6 Apr 2021 19:11:40 +0100 Subject: [PATCH] Check ConvexPolygonShape2D point count before calcuating moment of inertia --- servers/physics_2d/shape_2d_sw.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index e4f754561ef..99dd3bd3b87 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -627,6 +627,7 @@ bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vec real_t ConvexPolygonShape2DSW::get_moment_of_inertia(real_t p_mass, const Size2 &p_scale) const { + ERR_FAIL_COND_V_MSG(point_count == 0, 0, "Convex polygon shape has no points."); Rect2 aabb; aabb.position = points[0].pos * p_scale; for (int i = 0; i < point_count; i++) {