[PATCH vkd3d 2/4] vkd3d-shader: Fix out of bound array accesses.

Isabella Bosia ibosia at codeweavers.com
Tue Sep 15 12:05:10 CDT 2020


Signed-off-by: Isabella Bosia <ibosia at codeweavers.com>
---
 libs/vkd3d-shader/dxbc.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c
index 973a80d..a62974a 100644
--- a/libs/vkd3d-shader/dxbc.c
+++ b/libs/vkd3d-shader/dxbc.c
@@ -1787,7 +1787,13 @@ static void shader_sm4_read_instruction_modifier(DWORD modifier, struct vkd3d_sh
 
             if ((components & 0xfff0) != (components & 0xf) * 0x1110)
                 FIXME("Components (%#x) have different data types.\n", components);
-            ins->resource_data_type = data_type_table[data_type];
+            if (data_type < ARRAY_SIZE(data_type_table))
+                ins->resource_data_type = data_type_table[data_type];
+            else
+            {
+                FIXME("Unhandled data type %#x.\n", data_type);
+                ins->resource_data_type = VKD3D_DATA_FLOAT;
+            }
             break;
         }
 
@@ -1796,7 +1802,13 @@ static void shader_sm4_read_instruction_modifier(DWORD modifier, struct vkd3d_sh
             enum vkd3d_sm4_resource_type resource_type
                     = (modifier & VKD3D_SM5_MODIFIER_RESOURCE_TYPE_MASK) >> VKD3D_SM5_MODIFIER_RESOURCE_TYPE_SHIFT;
 
-            ins->resource_type = resource_type_table[resource_type];
+            if (resource_type < ARRAY_SIZE(resource_type_table))
+                ins->resource_type = resource_type_table[resource_type];
+            else
+            {
+                FIXME("Unhandled resource type %#x.\n", resource_type);
+                ins->resource_type = VKD3D_SHADER_RESOURCE_NONE;
+            }
             break;
         }
 
-- 
2.25.1




More information about the wine-devel mailing list