Commit ee57e19b authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

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

parent 7983d997
......@@ -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();
......
......@@ -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);
......
......@@ -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);
......
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