[PATCH vkd3d v3 3/6] vkd3d-shader: Assert that we don't read out of bounds of the base_types array.

Zebediah Figura zfigura at codeweavers.com
Sat Feb 27 18:03:11 CST 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 libs/vkd3d-shader/hlsl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index fbbe001a..1d767777 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -675,14 +675,17 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct vkd3d_string_buffer_cache
     switch (type->type)
     {
         case HLSL_CLASS_SCALAR:
+            assert(type->base_type < ARRAY_SIZE(base_types));
             vkd3d_string_buffer_printf(string, "%s", base_types[type->base_type]);
             return string;
 
         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);
             return string;
 
         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);
             return string;
 
-- 
2.30.1




More information about the wine-devel mailing list