From ab280de765131d7723b4d3f1a3066d26d63d79a7 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 27 Sep 2021 20:35:56 +0800 Subject: [PATCH] Validate before passing indices to meshoptimizer --- scene/resources/surface_tool.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index d5e370568db..a8cd8724084 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -1176,6 +1176,7 @@ Vector SurfaceTool::generate_lod(float p_threshold, int p_target_index_coun ERR_FAIL_COND_V(simplify_func == nullptr, 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); lod.resize(index_array.size()); LocalVector vertices; //uses floats