vkd3d-shader: Assert that we don't read out of bounds of the base_types array.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-27 18:03:11 -06:00 committed by Alexandre Julliard
parent 35105d4e29
commit 8d444ebbfc

View File

@ -675,14 +675,17 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct vkd3d_string_buffer_cache
switch (type->type) switch (type->type)
{ {
case HLSL_CLASS_SCALAR: case HLSL_CLASS_SCALAR:
assert(type->base_type < ARRAY_SIZE(base_types));
vkd3d_string_buffer_printf(string, "%s", base_types[type->base_type]); vkd3d_string_buffer_printf(string, "%s", base_types[type->base_type]);
return string; return string;
case HLSL_CLASS_VECTOR: case HLSL_CLASS_VECTOR:
assert(type->base_type < ARRAY_SIZE(base_types));
vkd3d_string_buffer_printf(string, "%s%u", base_types[type->base_type], type->dimx); vkd3d_string_buffer_printf(string, "%s%u", base_types[type->base_type], type->dimx);
return string; return string;
case HLSL_CLASS_MATRIX: case HLSL_CLASS_MATRIX:
assert(type->base_type < ARRAY_SIZE(base_types));
vkd3d_string_buffer_printf(string, "%s%ux%u", base_types[type->base_type], type->dimx, type->dimy); vkd3d_string_buffer_printf(string, "%s%ux%u", base_types[type->base_type], type->dimx, type->dimy);
return string; return string;