Browse Source

Fix unchecked array access in build_*_planes

Delf Neumärker 4 years ago
parent
commit
f054f760e6
1 changed files with 6 additions and 0 deletions
  1. 6 0
      core/math/geometry_3d.cpp

+ 6 - 0
core/math/geometry_3d.cpp

@@ -775,6 +775,8 @@ Vector<Plane> Geometry3D::build_box_planes(const Vector3 &p_extents) {
 }
 }
 
 
 Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height, int p_sides, Vector3::Axis p_axis) {
 Vector<Plane> Geometry3D::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, Vector<Plane>());
+
 	Vector<Plane> planes;
 	Vector<Plane> planes;
 
 
 	const double sides_step = Math_TAU / p_sides;
 	const double sides_step = Math_TAU / p_sides;
@@ -796,6 +798,8 @@ Vector<Plane> Geometry3D::build_cylinder_planes(real_t p_radius, real_t p_height
 }
 }
 
 
 Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
 Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p_lons, Vector3::Axis p_axis) {
+	ERR_FAIL_INDEX_V(p_axis, 3, Vector<Plane>());
+
 	Vector<Plane> planes;
 	Vector<Plane> planes;
 
 
 	Vector3 axis;
 	Vector3 axis;
@@ -827,6 +831,8 @@ Vector<Plane> Geometry3D::build_sphere_planes(real_t p_radius, int p_lats, int p
 }
 }
 
 
 Vector<Plane> Geometry3D::build_capsule_planes(real_t p_radius, real_t p_height, int p_sides, int p_lats, Vector3::Axis p_axis) {
 Vector<Plane> Geometry3D::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, Vector<Plane>());
+
 	Vector<Plane> planes;
 	Vector<Plane> planes;
 
 
 	Vector3 axis;
 	Vector3 axis;