From 1a9f2f827f539fa95075dca17ffdb0832652a6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Aug 2026 15:58:56 +0200 Subject: [PATCH] DrawBuffer::V(): don't overflow verts_ in release builds The only guard against writing past the fixed 65536-entry verts_ array was _dbg_assert_msg_, which is compiled out entirely outside _DEBUG - a large enough single batch (e.g. Circle()/CircleSegment() with a big segment count, or a large UI list without an intervening Flush()) silently corrupted the heap in release builds. Added a real bounds check that drops the vertex instead. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY --- Common/Render/DrawBuffer.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Common/Render/DrawBuffer.h b/Common/Render/DrawBuffer.h index c73abae598..94e5e56095 100644 --- a/Common/Render/DrawBuffer.h +++ b/Common/Render/DrawBuffer.h @@ -89,6 +89,11 @@ public: void V(float x, float y, float z, uint32_t color, float u, float v) { _dbg_assert_msg_(count_ < MAX_VERTS, "Overflowed the DrawBuffer"); + if (count_ >= MAX_VERTS) { + // _dbg_assert_msg_ above is compiled out in release builds - don't write + // past the end of verts_ there either, just drop the vertex. + return; + } #ifdef _DEBUG if (my_isnanorinf(x) || my_isnanorinf(y) || my_isnanorinf(z)) {