ddraw: Reject setting a 0 material handle in d3d_viewport_SetBackground().

This commit is contained in:
Henri Verbeet 2014-04-29 22:02:47 +02:00 committed by Alexandre Julliard
parent 91a615ee4d
commit 4ff220f94b
1 changed files with 4 additions and 25 deletions

View File

@ -524,39 +524,18 @@ static HRESULT WINAPI d3d_viewport_LightElements(IDirect3DViewport3 *iface,
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
/***************************************************************************** static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE material)
* IDirect3DViewport3::SetBackground
*
* Sets the background material
*
* Params:
* hMat: Handle from a IDirect3DMaterial interface
*
* Returns:
* D3D_OK on success
*
*****************************************************************************/
static HRESULT WINAPI d3d_viewport_SetBackground(IDirect3DViewport3 *iface, D3DMATERIALHANDLE hMat)
{ {
struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface); struct d3d_viewport *viewport = impl_from_IDirect3DViewport3(iface);
struct d3d_material *m; struct d3d_material *m;
TRACE("iface %p, material %#x.\n", iface, hMat); TRACE("iface %p, material %#x.\n", iface, material);
wined3d_mutex_lock(); wined3d_mutex_lock();
if (!hMat) if (!(m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, material - 1, DDRAW_HANDLE_MATERIAL)))
{ {
viewport->background = NULL; WARN("Invalid material handle %#x.\n", material);
TRACE("Setting background to NULL\n");
wined3d_mutex_unlock();
return D3D_OK;
}
m = ddraw_get_object(&viewport->ddraw->d3ddevice->handle_table, hMat - 1, DDRAW_HANDLE_MATERIAL);
if (!m)
{
WARN("Invalid material handle.\n");
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }