d3d10/effect: Fix index access in GetDepthStencilState().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-01-21 10:26:27 +03:00 committed by Alexandre Julliard
parent 2149beff79
commit bf89b610d3
2 changed files with 15 additions and 7 deletions
dlls/d3d10

View File

@ -8772,17 +8772,15 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_depth_stencil_variable_GetDepthSte
TRACE("iface %p, index %u, depth_stencil_state %p.\n", iface, index, depth_stencil_state);
if (v->type->element_count)
v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index));
else if (index)
return E_FAIL;
if (v->type->basetype != D3D10_SVT_DEPTHSTENCIL)
if (!iface->lpVtbl->IsValid(iface))
{
WARN("Variable is not a depth stencil state.\n");
WARN("Invalid variable.\n");
return E_FAIL;
}
if (!(v = d3d10_get_state_variable(v, index, &v->effect->ds_states)))
return E_FAIL;
if ((*depth_stencil_state = v->u.state.object.depth_stencil))
ID3D10DepthStencilState_AddRef(*depth_stencil_state);

View File

@ -4559,8 +4559,18 @@ static void test_effect_state_groups(void)
ds_desc.BackFace.StencilPassOp);
ok(ds_desc.BackFace.StencilFunc == D3D10_COMPARISON_GREATER_EQUAL, "Got unexpected BackFaceStencilFunc %#x.\n",
ds_desc.BackFace.StencilFunc);
hr = d->lpVtbl->GetDepthStencilState(d, 0, &ds_state);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3D10DepthStencilState_GetDesc(ds_state, &ds_desc);
ok(ds_desc.DepthEnable, "Got unexpected DepthEnable %#x.\n", ds_desc.DepthEnable);
ID3D10DepthStencilState_Release(ds_state);
d->lpVtbl->GetBackingStore(d, 1, &ds_desc);
ok(!ds_desc.DepthEnable, "Got unexpected DepthEnable %#x.\n", ds_desc.DepthEnable);
hr = d->lpVtbl->GetDepthStencilState(d, 1, &ds_state);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3D10DepthStencilState_GetDesc(ds_state, &ds_desc);
ok(!ds_desc.DepthEnable, "Got unexpected DepthEnable %#x.\n", ds_desc.DepthEnable);
ID3D10DepthStencilState_Release(ds_state);
v = effect->lpVtbl->GetVariableByName(effect, "rast_state");
r = v->lpVtbl->AsRasterizer(v);