From 8db4c5a9d3061a396a2e1c7961963c67f1fb9cfe Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 25 Feb 2014 10:04:49 -0800 Subject: [PATCH] Fixed crash if the input data pitch is larger than the locked texture pitch --- src/render/direct3d/SDL_render_d3d.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index afa6fe92f..0caa8d267 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1009,6 +1009,12 @@ D3D_UpdateTextureInternal(IDirect3DTexture9 *texture, Uint32 format, SDL_bool fu if (length == pitch && length == locked.Pitch) { SDL_memcpy(dst, src, length*h); } else { + if (length > pitch) { + length = pitch; + } + if (length > locked.Pitch) { + length = locked.Pitch; + } for (row = 0; row < h; ++row) { SDL_memcpy(dst, src, length); src += pitch;