From 5d0919855e8b580d46b43662185e36a3688476a6 Mon Sep 17 00:00:00 2001 From: Chris Genova Date: Fri, 7 Nov 2025 17:32:37 -0500 Subject: [PATCH] D3D12 GPU: Prevent reading out of bounds when uploading textures. When the upload needs realignment, a new buffer is created to do the upload, and the source data is copied to the new buffer. This commit fixes the issue where the memcopy can read off the end of the source buffer since it is reading based on destination pitch instead of source pitch. (cherry picked from commit 6a01d6e7d30d83ae76f567d359754749bb1c5d72) --- src/gpu/d3d12/SDL_gpu_d3d12.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gpu/d3d12/SDL_gpu_d3d12.c b/src/gpu/d3d12/SDL_gpu_d3d12.c index 92b9b7a7ad..e129587742 100644 --- a/src/gpu/d3d12/SDL_gpu_d3d12.c +++ b/src/gpu/d3d12/SDL_gpu_d3d12.c @@ -5953,7 +5953,7 @@ static void D3D12_UploadToTexture( SDL_memcpy( temporaryBuffer->mapPointer + (sliceIndex * rowsPerSlice) + (rowIndex * alignedRowPitch), transferBufferContainer->activeBuffer->mapPointer + source->offset + (sliceIndex * bytesPerSlice) + (rowIndex * rowPitch), - alignedRowPitch); + rowPitch); } Uint32 offset = source->offset + (sliceIndex * bytesPerSlice) + ((rowsPerSlice - 1) * rowPitch); SDL_memcpy(