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>
This commit is contained in:
Henri Verbeet 2017-05-02 15:31:04 +02:00 committed by Alexandre Julliard
parent 7f826a7131
commit fb4740bbb3
5 changed files with 42 additions and 8 deletions

View file

@ -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");

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);