Skip to content

Commit 6a01d6e

Browse files
ravencggslouken
authored andcommitted
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.
1 parent 1fb663b commit 6a01d6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/gpu/d3d12/SDL_gpu_d3d12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5941,7 +5941,7 @@ static void D3D12_UploadToTexture(
59415941
SDL_memcpy(
59425942
temporaryBuffer->mapPointer + (sliceIndex * rowsPerSlice) + (rowIndex * alignedRowPitch),
59435943
transferBufferContainer->activeBuffer->mapPointer + source->offset + (sliceIndex * bytesPerSlice) + (rowIndex * rowPitch),
5944-
alignedRowPitch);
5944+
rowPitch);
59455945
}
59465946
Uint32 offset = source->offset + (sliceIndex * bytesPerSlice) + ((rowsPerSlice - 1) * rowPitch);
59475947
SDL_memcpy(

0 commit comments

Comments
 (0)