=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: d3d9: Validate adapter format in CheckDeviceFormat().
Alexandre Julliard
julliard at winehq.org
Tue Apr 17 14:53:59 CDT 2018
Module: wine
Branch: master
Commit: 17e04ba43972f259721dae004513251f44ef641c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=17e04ba43972f259721dae004513251f44ef641c
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Tue Apr 17 14:26:53 2018 +0200
d3d9: Validate adapter format in CheckDeviceFormat().
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/d3d9/directx.c | 6 ++++++
dlls/d3d9/tests/device.c | 17 +++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index cdce669..98f4a99 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -254,6 +254,12 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter,
TRACE("iface %p, adapter %u, device_type %#x, adapter_format %#x, usage %#x, resource_type %#x, format %#x.\n",
iface, adapter, device_type, adapter_format, usage, resource_type, format);
+ if (!adapter_format)
+ {
+ WARN("Invalid adapter format.\n");
+ return D3DERR_INVALIDCALL;
+ }
+
usage = usage & (WINED3DUSAGE_MASK | WINED3DUSAGE_QUERY_MASK);
switch (resource_type)
{
diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c
index dc900f1..0eba766 100644
--- a/dlls/d3d9/tests/device.c
+++ b/dlls/d3d9/tests/device.c
@@ -11638,6 +11638,7 @@ static void test_check_device_format(void)
D3DFORMAT adapter_format, format;
BOOL render_target_supported;
+ D3DDEVTYPE device_type;
unsigned int i, j;
IDirect3D9 *d3d;
HRESULT hr;
@@ -11660,6 +11661,22 @@ static void test_check_device_format(void)
ok(FAILED(hr), "Got unexpected hr %#x.\n", hr);
}
+ for (device_type = D3DDEVTYPE_HAL; device_type < D3DDEVTYPE_NULLREF; ++device_type)
+ {
+ hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
+ 0, D3DRTYPE_SURFACE, D3DFMT_A8R8G8B8);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+ hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
+ 0, D3DRTYPE_TEXTURE, D3DFMT_A8R8G8B8);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+ hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
+ 0, D3DRTYPE_SURFACE, D3DFMT_X8R8G8B8);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+ hr = IDirect3D9_CheckDeviceFormat(d3d, 0, device_type, D3DFMT_UNKNOWN,
+ 0, D3DRTYPE_TEXTURE, D3DFMT_X8R8G8B8);
+ ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x, device type %#x.\n", hr, device_type);
+ }
+
hr = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8,
0, D3DRTYPE_VERTEXBUFFER, D3DFMT_VERTEXDATA);
todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr);
More information about the wine-cvs
mailing list