diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 578d8e4..a36784a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2699,6 +2699,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W TRACE("(%p)->state = %s(%d), value = %d\n", This, debug_d3drenderstate(State), State, Value); + if (State < 1 || State > WINEHIGHEST_RENDER_STATE) + { + WARN("Tried to set invalid render state %#x.\n", State); + return WINED3D_OK; + } + This->updateStateBlock->changed.renderState[State >> 5] |= 1 << (State & 0x1f); This->updateStateBlock->renderState[State] = Value; @@ -2711,8 +2717,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderState(IWineD3DDevice *iface, W /* Compared here and not before the assignment to allow proper stateblock recording */ if(Value == oldValue) { TRACE("Application is setting the old value over, nothing to do\n"); - } else { - IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State)); + } + else + { + if (!This->StateTable[STATE_RENDER(State)].representative) + { + FIXME("State %s is invalid.\n", debug_d3drenderstate(State)); + } + else IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(State)); } return WINED3D_OK;