From 1904e60f7cf40565683cca7ef7e12d41b775cdca Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 29 Jun 2026 23:09:03 +0200 Subject: [PATCH] [util/gpu] Guard D3D11 atlas allocation (#6043) The D3D11 demo atlas backend advanced its cursor and copied glyph data into the shadow buffer without checking the fixed atlas capacity. Long sessions could therefore write past the end of the shadow buffer once the atlas filled. Match the other demo atlas backends by failing before advancing the cursor when the requested glyph data does not fit. Testing: meson test -C build Assisted-by: OpenAI Codex --- util/gpu/demo-renderer-d3d11.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/gpu/demo-renderer-d3d11.cc b/util/gpu/demo-renderer-d3d11.cc index c29ec6255..def5dd696 100644 --- a/util/gpu/demo-renderer-d3d11.cc +++ b/util/gpu/demo-renderer-d3d11.cc @@ -167,6 +167,8 @@ struct demo_renderer_d3d11_t : demo_renderer_t backend.alloc = [](void *ctx_, const char *data, unsigned len_bytes) -> unsigned { auto *self = (demo_renderer_d3d11_t *) ctx_; unsigned len_texels = len_bytes / 8; + if (self->atlas.cursor + len_texels > self->atlas.capacity) + die ("Ran out of atlas memory"); unsigned offset = self->atlas.cursor; self->atlas.cursor += len_texels; const int16_t *src = (const int16_t *) data;