summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2021-10-18 07:51:43 +0200
committerGitHub <noreply@github.com>2021-10-18 07:51:43 +0200
commitb6ee9ed8c52883084054223a370fd3ef3c3c733b (patch)
tree275abc24faee7049ef2695728420fa92c55db31b
parent468b987aa38b21b55c1cd8a8d4c03b8e1b2a1373 (diff)
parent5d96124af6fee0ae99ccbb0cb5f05b4550dccdb4 (diff)
Merge pull request #53889 from Klowner/surfacetool-generate-lod-assert-crash
Add check to SurfaceTool.generate_lod(); ensure target index count >=…
-rw-r--r--scene/resources/surface_tool.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index a8cd872408..455af8a40c 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -1174,9 +1174,11 @@ Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun
Vector<int> lod;
ERR_FAIL_COND_V(simplify_func == nullptr, lod);
+ ERR_FAIL_COND_V(p_target_index_count < 0, lod);
ERR_FAIL_COND_V(vertex_array.size() == 0, lod);
ERR_FAIL_COND_V(index_array.size() == 0, lod);
ERR_FAIL_COND_V(index_array.size() % 3 != 0, lod);
+ ERR_FAIL_COND_V(index_array.size() < (unsigned int)p_target_index_count, lod);
lod.resize(index_array.size());
LocalVector<float> vertices; //uses floats