[PATCH 2/5] ddraw: Validate that non-fill blits have a source surface in ddraw_surface7_Blt().
Henri Verbeet
hverbeet at codeweavers.com
Tue May 2 04:35:27 CDT 2017
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
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 a25a07b..30eb010 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -11396,21 +11396,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);
--
2.1.4
More information about the wine-patches
mailing list