[WINESYNC] d3dx9: Use an assert() to validate access to const_tbl[].
authorwinesync <ros-dev@reactos.org>
Mon, 21 Sep 2020 21:07:32 +0000 (23:07 +0200)
committerJérôme Gardou <jerome.gardou@reactos.org>
Thu, 4 Feb 2021 15:37:06 +0000 (16:37 +0100)
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>

dll/directx/wine/d3dx9_36/effect.c
sdk/tools/winesync/d3dx9.cfg

index c38ca0f..8670daa 100644 (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)
index 8db3c52..7ebb6f8 100644 (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}