nir: Don't print swizzles when there are more than 4 components
authorMatt Turner <mattst88@gmail.com>
Sat, 28 Oct 2017 01:15:46 +0000 (18:15 -0700)
committerMatt Turner <mattst88@gmail.com>
Wed, 8 Nov 2017 21:22:26 +0000 (13:22 -0800)
... as can happen with various types like mat4, or else we'll smash the
stack writing past the end of components_local[].

Fixes: 5a0d3e1129b7 ("nir: Print the components referenced for split or
                      packed shader in/outs.")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_print.c

index 4b7ad5c6ba2584c211aceb5af3d48c31b571674e..fcc8025346ed0823cf5d5736e2324f9cb9714a9e 100644 (file)
@@ -457,7 +457,7 @@ print_var_decl(nir_variable *var, print_state *state)
       switch (var->data.mode) {
       case nir_var_shader_in:
       case nir_var_shader_out:
-         if (num_components != 4 && num_components != 0) {
+         if (num_components < 4 && num_components != 0) {
             const char *xyzw = "xyzw";
             for (int i = 0; i < num_components; i++)
                components_local[i + 1] = xyzw[i + var->data.location_frac];