pan/midgard: Don't crash with constants on unknown ops
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 13 Feb 2020 22:12:51 +0000 (17:12 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sun, 16 Feb 2020 14:16:50 +0000 (09:16 -0500)
Just use a dummy name instead.. we can't know a priori what type an
unknown op will consume, but we don't want to dereference a null
pointer.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fixes: 24360966ab3 ("panfrost/midgard: Prettify embedded constant
prints")

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3835>

src/panfrost/midgard/midgard_print.c

index 85a1d98..94a0f1a 100644 (file)
@@ -110,6 +110,10 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned
         bool is_sint = false, is_uint = false, is_hex = false;
         const char *opname = alu_opcode_props[op].name;
 
+        /* Add a sentinel name to prevent crashing */
+        if (!opname)
+                opname = "unknown";
+
         if (opname[0] == 'u') {
                 /* If the opcode starts with a 'u' we are sure we deal with an
                  * unsigned int operation