Fix SurfaceTool crash with invalid bone/weight count

Fixes #53191.
This commit is contained in:
Rémi Verschelde 2023-02-12 14:14:03 +01:00
parent 3fcd989972
commit 77b415ab6d
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -648,7 +648,7 @@ Array SurfaceTool::commit_to_arrays() {
for (uint32_t idx = 0; idx < vertex_array.size(); idx++) {
const Vertex &v = vertex_array[idx];
if (v.bones.size() > count) {
if (v.bones.size() != count) {
ERR_PRINT_ONCE(vformat("Invalid bones size %d vs count %d", v.bones.size(), count));
continue;
}
@ -672,7 +672,7 @@ Array SurfaceTool::commit_to_arrays() {
for (uint32_t idx = 0; idx < vertex_array.size(); idx++) {
const Vertex &v = vertex_array[idx];
if (v.weights.size() > count) {
if (v.weights.size() != count) {
ERR_PRINT_ONCE(vformat("Invalid weight size %d vs count %d", v.weights.size(), count));
continue;
}