ddraw: SetPrivateData(..., data = NULL, ...) is not valid.

This commit is contained in:
Stefan Dösinger 2014-04-07 22:27:32 +02:00 committed by Alexandre Julliard
parent 7983d9974b
commit ee57e19b40
3 changed files with 24 additions and 0 deletions

View File

@ -2254,6 +2254,12 @@ static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(tag), data, size, flags);
if (!data)
{
WARN("data is NULL, returning DDERR_INVALIDPARAMS.\n");
return DDERR_INVALIDPARAMS;
}
wined3d_mutex_lock();
hr = wined3d_private_store_set_private_data(&surface->private_store, tag, data, size, flags);
wined3d_mutex_unlock();

View File

@ -6103,6 +6103,15 @@ static void test_private_data(void)
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
/* NULL pointers are not valid, but don't cause a crash. */
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */
hr = IDirectDrawSurface4_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
0, DDSPD_IUNKNOWNPOINTER);

View File

@ -5958,6 +5958,15 @@ static void test_private_data(void)
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
/* NULL pointers are not valid, but don't cause a crash. */
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL,
sizeof(IUnknown *), DDSPD_IUNKNOWNPOINTER);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 0, 0);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, NULL, 1, 0);
ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
/* DDSPD_IUNKNOWNPOINTER needs sizeof(IUnknown *) bytes of data. */
hr = IDirectDrawSurface7_SetPrivateData(surface, &ddraw_private_data_test_guid, ddraw,
0, DDSPD_IUNKNOWNPOINTER);