From f22249cef54b101e83e00bb4f7ccde8cdb4c09ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 20 Dec 2023 18:31:49 +0100 Subject: [PATCH] Reject zero-vertex-count draws. I thought all the code was safe against it, but it isn't. --- GPU/Common/DrawEngineCommon.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 83aaeb7164..fc0200d76d 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -910,6 +910,10 @@ bool DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti if ((vertexCount < 2 && prim > 0) || (prim > GE_PRIM_LINE_STRIP && prim != GE_PRIM_RECTANGLES)) { return false; } + if (vertexCount <= 0) { + // Unfortunately we need to do this check somewhere since GetIndexBounds doesn't handle zero-length arrays. + return false; + } } bool applySkin = (vertTypeID & GE_VTYPE_WEIGHT_MASK) && decOptions_.applySkinInDecode;