[WINESYNC] d3dx9: Use an assert() to validate access to const_tbl[].

This check is essentially validating that the hardcoded state_table[]
has reasonable values for the shader constant states. Use ARRAY_SIZE()
to avoid warnings if the compiler chooses an unsigned integer to back
enum SHADER_CONSTANT_TYPE.

Based on an idea by Henri Verbeet.

Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id cfc533b40d2d1426a8f05501152b28aa1ec78f07 by Matteo Bruni <mbruni@codeweavers.com>
This commit is contained in:
winesync 2020-09-21 23:07:32 +02:00 committed by Jérôme Gardou
parent e6e305520c
commit 777269ea64
2 changed files with 2 additions and 6 deletions

View file

@ -1473,11 +1473,7 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD
D3DXVECTOR4 value;
HRESULT ret;
if (op < 0 || op > SCT_PSINT)
{
FIXME("Unknown op %u.\n", op);
return D3DERR_INVALIDCALL;
}
assert(op < ARRAY_SIZE(const_tbl));
element_count = param->bytes / const_tbl[op].elem_size;
TRACE("%s, index %u, element_count %u.\n", const_tbl[op].name, index, element_count);
if (param->type != const_tbl[op].type)

View file

@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc
include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h,
include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h}
tags: {wine: 9796bdc966a89cd31829f3a094bb37ec71e21871}
tags: {wine: cfc533b40d2d1426a8f05501152b28aa1ec78f07}