Module: vkd3d Branch: master Commit: ed9e236b0173e89265453b6bc993fdce47ea7122 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/ed9e236b0173e89265453b6bc993fd...
Author: Francisco Casas fcasas@codeweavers.com Date: Tue Aug 22 03:40:50 2023 -0400
vkd3d-shader/tpf: Avoid reading constant value components beyond type's width (Valgrind).
We are passing map writemasks that may have more components than the constant's data type, so a (j < width) check is added to avoid reading components from the constant that are not intended to be used.
Remaining values in the register are initialized to zero.
---
libs/vkd3d-shader/tpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 550f9b27..cf2cc0d1 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3715,8 +3715,10 @@ static void sm4_src_from_constant_value(struct sm4_src_register *src, src->reg.dim = VKD3D_SM4_DIMENSION_VEC4; for (i = 0; i < 4; ++i) { - if (map_writemask & (1u << i)) + if ((map_writemask & (1u << i)) && (j < width)) src->reg.immconst_uint[i] = value->u[j++].u; + else + src->reg.immconst_uint[i] = 0; } } }