Module: wine Branch: master Commit: cfc533b40d2d1426a8f05501152b28aa1ec78f07 URL: https://source.winehq.org/git/wine.git/?a=commit;h=cfc533b40d2d1426a8f055011...
Author: Matteo Bruni mbruni@codeweavers.com Date: Tue Mar 24 15:17:16 2020 +0100
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
---
dlls/d3dx9_36/effect.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 88168df1e1..525b87340b 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -1469,11 +1469,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)