Fixed crash if the input data pitch is larger than the locked texture pitch
authorSam Lantinga <slouken@libsdl.org>
Tue, 25 Feb 2014 10:04:49 -0800
changeset 8255 49af9be342cd
parent 8254 f97b5166c158
child 8256 bcfb214c2950
Fixed crash if the input data pitch is larger than the locked texture pitch
src/render/direct3d/SDL_render_d3d.c
--- a/src/render/direct3d/SDL_render_d3d.c	Mon Feb 24 23:09:35 2014 -0800
+++ b/src/render/direct3d/SDL_render_d3d.c	Tue Feb 25 10:04:49 2014 -0800
@@ -1009,6 +1009,12 @@
     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;