Commit 2b04143e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dxva2: Fix valid handle range test.

parent 7bbd46ba
......@@ -562,7 +562,7 @@ static HRESULT WINAPI device_manager_OpenDeviceHandle(IDirect3DDeviceManager9 *i
static HRESULT device_manager_get_handle_index(struct device_manager *manager, HANDLE hdevice, size_t *idx)
{
if (hdevice > ULongToHandle(manager->count))
if (!hdevice || hdevice > ULongToHandle(manager->count))
return E_HANDLE;
*idx = (ULONG_PTR)hdevice - 1;
return S_OK;
......
......@@ -115,6 +115,9 @@ static void test_device_manager(void)
hr = IDirect3DDeviceManager9_LockDevice(manager, 0, &device2, FALSE);
ok(hr == DXVA2_E_NOT_INITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, 0);
ok(hr == E_HANDLE, "Unexpected hr %#x.\n", hr);
/* Invalid token. */
hr = IDirect3DDeviceManager9_ResetDevice(manager, device, token + 1);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
......@@ -123,9 +126,13 @@ static void test_device_manager(void)
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
refcount = get_refcount(device);
hr = IDirect3DDeviceManager9_CloseDeviceHandle(manager, 0);
ok(hr == E_HANDLE, "Unexpected hr %#x.\n", hr);
handle1 = NULL;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle1);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ok(!!handle1, "Unexpected handle value.\n");
refcount2 = get_refcount(device);
ok(refcount2 == refcount, "Unexpected refcount %d.\n", refcount);
......@@ -152,6 +159,9 @@ static void test_device_manager(void)
hr = IDirect3DDeviceManager9_TestDevice(manager, handle1);
ok(hr == E_HANDLE, "Unexpected hr %#x.\n", hr);
hr = IDirect3DDeviceManager9_TestDevice(manager, 0);
ok(hr == E_HANDLE, "Unexpected hr %#x.\n", hr);
handle = NULL;
hr = IDirect3DDeviceManager9_OpenDeviceHandle(manager, &handle);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment