From 8b94ba1db127f7d75625fd9f6ac2fe4e6ec09c9e Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Tue, 2 Nov 2021 16:52:36 +0300 Subject: [PATCH] Prevent MeshDataTool from crashing due to invalid bones/weights arrays (cherry picked from commit ec15227be81c2bd7e08103e7c46cea8cb5d44f49) --- scene/resources/mesh_data_tool.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index 3e8422ed0d1..bc269a22a5e 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -420,6 +420,7 @@ Vector MeshDataTool::get_vertex_bones(int p_idx) const { void MeshDataTool::set_vertex_bones(int p_idx, const Vector &p_bones) { ERR_FAIL_INDEX(p_idx, vertices.size()); + ERR_FAIL_COND(p_bones.size() != 4); vertices.write[p_idx].bones = p_bones; format |= Mesh::ARRAY_FORMAT_BONES; } @@ -431,6 +432,7 @@ Vector MeshDataTool::get_vertex_weights(int p_idx) const { } void MeshDataTool::set_vertex_weights(int p_idx, const Vector &p_weights) { ERR_FAIL_INDEX(p_idx, vertices.size()); + ERR_FAIL_COND(p_weights.size() != 4); vertices.write[p_idx].weights = p_weights; format |= Mesh::ARRAY_FORMAT_WEIGHTS; }