Browse Source

Fix unchecked array access in build_*_planes

(cherry picked from commit f054f760e64b3b1768e9f8b6928bd38d6c41532b)
Delf Neumärker 4 years ago
parent
commit
4f891b7060
1 changed files with 3 additions and 0 deletions
  1. 3 0
      core/math/geometry.cpp

+ 3 - 0
core/math/geometry.cpp

@@ -877,6 +877,7 @@ PoolVector<Plane> Geometry::build_box_planes(const Vector3 &p_extents) {
 }
 
 PoolVector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
+	ERR_FAIL_INDEX_V(p_axis, 3, PoolVector<Plane>());
 
 	PoolVector<Plane> planes;
 
@@ -899,6 +900,7 @@ PoolVector<Plane> Geometry::build_cylinder_planes(real_t p_radius, real_t p_heig
 }
 
 PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
+	ERR_FAIL_INDEX_V(p_axis, 3, PoolVector<Plane>());
 
 	PoolVector<Plane> planes;
 
@@ -932,6 +934,7 @@ PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int
 }
 
 PoolVector<Plane> Geometry::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
+	ERR_FAIL_INDEX_V(p_axis, 3, PoolVector<Plane>());
 
 	PoolVector<Plane> planes;