From c2ba65e972d3ff25f1a2947cb222cee1fccdca6a Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Tue, 9 Jul 2024 15:47:38 +0200 Subject: [PATCH] AtlasEngine: Fix a buffer overrun --- src/renderer/atlas/BackendD3D.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/atlas/BackendD3D.cpp b/src/renderer/atlas/BackendD3D.cpp index a9e81422d0a..33cb3147355 100644 --- a/src/renderer/atlas/BackendD3D.cpp +++ b/src/renderer/atlas/BackendD3D.cpp @@ -1069,12 +1069,13 @@ void BackendD3D::_uploadBackgroundBitmap(const RenderingPayload& p) auto src = std::bit_cast(p.backgroundBitmap.data()); const auto srcEnd = std::bit_cast(p.backgroundBitmap.data() + p.backgroundBitmap.size()); + const auto srcWidth = p.s->viewportCellCount.x * sizeof(u32); const auto srcStride = p.colorBitmapRowStride * sizeof(u32); auto dst = static_cast(mapped.pData); while (src < srcEnd) { - memcpy(dst, src, srcStride); + memcpy(dst, src, srcWidth); src += srcStride; dst += mapped.RowPitch; }