Józef Kucia : d3d8: Validate adapter format in CheckDeviceFormat().
Module: wine Branch: master Commit: aea576b10f4f72941a8fb3da94ee3959ef0ae384 URL: http://source.winehq.org/git/wine.git/?a=commit;h=aea576b10f4f72941a8fb3da94... Author: Józef Kucia <jkucia(a)codeweavers.com> Date: Wed May 31 11:43:16 2017 +0200 d3d8: Validate adapter format in CheckDeviceFormat(). Signed-off-by: Józef Kucia <jkucia(a)codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/d3d8/directx.c | 6 ++++++ dlls/d3d8/tests/device.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index 107e32d..24bd831 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -241,6 +241,12 @@ static HRESULT WINAPI d3d8_CheckDeviceFormat(IDirect3D8 *iface, UINT adapter, D3 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/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 6b34ff1..54f6505 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -7925,12 +7925,29 @@ static void test_swapchain_parameters(void) static void test_check_device_format(void) { + D3DDEVTYPE device_type; IDirect3D8 *d3d; HRESULT hr; d3d = Direct3DCreate8(D3D_SDK_VERSION); ok(!!d3d, "Failed to create a D3D object.\n"); + for (device_type = D3DDEVTYPE_HAL; device_type <= D3DDEVTYPE_SW; ++device_type) + { + hr = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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 = IDirect3D8_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);
participants (1)
-
Alexandre Julliard