Mesa (master): intel/compiler: Handle invalid inputs to brw_reg_type_to_*()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 22 00:51:23 UTC 2020


Module: Mesa
Branch: master
Commit: 205cb8a1396b446646d6edaee6a96533da8e562d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=205cb8a1396b446646d6edaee6a96533da8e562d

Author: Matt Turner <mattst88 at gmail.com>
Date:   Thu Jan  2 14:57:56 2020 -0800

intel/compiler: Handle invalid inputs to brw_reg_type_to_*()

Necessary to handle these cases when we test fuzzed instructions.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2635>

---

 src/intel/compiler/brw_reg_type.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/intel/compiler/brw_reg_type.c b/src/intel/compiler/brw_reg_type.c
index 7a42f2ffbe6..c720542e3a0 100644
--- a/src/intel/compiler/brw_reg_type.c
+++ b/src/intel/compiler/brw_reg_type.c
@@ -479,6 +479,9 @@ brw_reg_type_to_size(enum brw_reg_type type)
       [BRW_REGISTER_TYPE_V]  = 2,
       [BRW_REGISTER_TYPE_UV] = 2,
    };
+   if (type >= ARRAY_SIZE(type_size))
+      return -1;
+
    return type_size[type];
 }
 
@@ -509,6 +512,9 @@ brw_reg_type_to_letters(enum brw_reg_type type)
       [BRW_REGISTER_TYPE_V]  = "V",
       [BRW_REGISTER_TYPE_UV] = "UV",
    };
+   if (type >= ARRAY_SIZE(letters))
+      return "INVALID";
+
    assert(type < ARRAY_SIZE(letters));
    return letters[type];
 }



More information about the mesa-commit mailing list