Module: wine Branch: master Commit: fb4740bbb39ddfd017387b18c40c8582166f746c URL: http://source.winehq.org/git/wine.git/?a=commit;h=fb4740bbb39ddfd017387b18c4...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue May 2 15:31:04 2017 +0200
ddraw: Validate that non-fill blits have a source surface in ddraw_surface7_Blt().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ddraw/surface.c | 6 ++++++ dlls/ddraw/tests/ddraw1.c | 7 +++++++ dlls/ddraw/tests/ddraw2.c | 7 +++++++ dlls/ddraw/tests/ddraw4.c | 15 +++++++++++---- dlls/ddraw/tests/ddraw7.c | 15 +++++++++++---- 5 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index a780f1a..394e915 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -1710,6 +1710,12 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Blt(IDirectDrawSurface7 * } }
+ if (!(flags & (DDBLT_COLORFILL | DDBLT_DEPTHFILL)) && !src_impl) + { + WARN("No source surface.\n"); + return DDERR_INVALIDPARAMS; + } + if (flags & DDBLT_KEYSRC && (!src_impl || !(src_impl->surface_desc.dwFlags & DDSD_CKSRCBLT))) { WARN("DDBLT_KEYSRC blit without color key in surface, returning DDERR_INVALIDPARAMS\n"); diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index ac4942d..c052c03 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -8863,6 +8863,13 @@ static void test_blt(void) hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, rt, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); + + hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); + + hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); }
IDirectDrawSurface_Release(surface); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 67a2b06..f81a296 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -9951,6 +9951,13 @@ static void test_blt(void) hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, rt, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); + + hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); + + hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); }
IDirectDrawSurface_Release(surface); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 763151a..f25b327 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -11395,21 +11395,28 @@ static void test_blt(void) hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- hr = IDirectDrawSurface_Blt(surface, NULL, surface, NULL, 0, NULL); + hr = IDirectDrawSurface4_Blt(surface, NULL, surface, NULL, 0, NULL); ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
- hr = IDirectDrawSurface_Blt(surface, NULL, rt, NULL, 0, NULL); + hr = IDirectDrawSurface4_Blt(surface, NULL, rt, NULL, 0, NULL); ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) { - hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect, surface, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
- hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect, rt, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); + + hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect, + NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); + + hr = IDirectDrawSurface4_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); }
IDirectDrawSurface4_Release(surface); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 79ce80f..354e872 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -11374,21 +11374,28 @@ static void test_blt(void) hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- hr = IDirectDrawSurface_Blt(surface, NULL, surface, NULL, 0, NULL); + hr = IDirectDrawSurface7_Blt(surface, NULL, surface, NULL, 0, NULL); ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
- hr = IDirectDrawSurface_Blt(surface, NULL, rt, NULL, 0, NULL); + hr = IDirectDrawSurface7_Blt(surface, NULL, rt, NULL, 0, NULL); ok(SUCCEEDED(hr), "Failed to blit, hr %#x.\n", hr);
for (i = 0; i < sizeof(test_data) / sizeof(*test_data); ++i) { - hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, surface, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr);
- hr = IDirectDrawSurface_Blt(surface, &test_data[i].dst_rect, + hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, rt, &test_data[i].src_rect, DDBLT_WAIT, NULL); ok(hr == test_data[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, test_data[i].hr); + + hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, + NULL, &test_data[i].src_rect, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); + + hr = IDirectDrawSurface7_Blt(surface, &test_data[i].dst_rect, NULL, NULL, DDBLT_WAIT, NULL); + ok(hr == DDERR_INVALIDPARAMS, "Test %u: Got unexpected hr %#x.\n", i, hr); }
IDirectDrawSurface7_Release(surface);