From d842d215df2e4a9d0ed6231232f6301d825da1d7 Mon Sep 17 00:00:00 2001 From: Chris Hutchinson Date: Mon, 13 Feb 2023 19:35:16 -0500 Subject: [PATCH] Prevent crash in ImmediateMesh.create_outline by ensuring that when no indices are specified, the number of vertices is at least a factor of 3. Fixes #73201 --- scene/resources/mesh.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index cf9baa29073..a7b53244e24 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -526,6 +526,9 @@ Ref Mesh::create_outline(float p_margin) const { vc = indices.size(); ir = indices.ptrw(); has_indices = true; + } else { + // Ensure there are enough vertices to construct at least one triangle. + ERR_FAIL_COND_V(vertices.size() % 3 != 0, Ref()); } HashMap normal_accum;