radeonsi: increase array size for shader inputs and outputs
authorMarek Olšák <maraeo@gmail.com>
Tue, 14 May 2013 17:37:17 +0000 (19:37 +0200)
committerMichel Dänzer <michel@daenzer.net>
Tue, 21 May 2013 15:47:44 +0000 (17:47 +0200)
and add assertions to prevent buffer overflow. This fixes corruption
of the si_shader struct.

NOTE: This is a candidate for the 9.1 branch.

[ Cherry-pick of r600g commit da33f9b919039442e9ab51f9b1d1c83a73607133 ]

Reviewed-by: Marek Olšák <maraeo@gmail.com>
src/gallium/drivers/radeonsi/radeonsi_shader.c
src/gallium/drivers/radeonsi/radeonsi_shader.h

index f9424360ba5f91f884beaac04748cef43562ef4c..bea2895bf0c949eb496d61914fbf302b74dc71aa 100644 (file)
@@ -589,6 +589,7 @@ static void si_llvm_emit_epilogue(struct lp_build_tgsi_context * bld_base)
                switch (d->Declaration.File) {
                case TGSI_FILE_INPUT:
                        i = shader->ninput++;
+                       assert(i < Elements(shader->input));
                        shader->input[i].name = d->Semantic.Name;
                        shader->input[i].sid = d->Semantic.Index;
                        shader->input[i].interpolate = d->Interp.Interpolate;
@@ -597,6 +598,7 @@ static void si_llvm_emit_epilogue(struct lp_build_tgsi_context * bld_base)
 
                case TGSI_FILE_OUTPUT:
                        i = shader->noutput++;
+                       assert(i < Elements(shader->output));
                        shader->output[i].name = d->Semantic.Name;
                        shader->output[i].sid = d->Semantic.Index;
                        shader->output[i].interpolate = d->Interp.Interpolate;
index 1552dc2df54a268fa9b632c0ca3f9c116eddeeae..0fbd601ad34f516426f846c48fb6a4a497256c5e 100644 (file)
@@ -101,10 +101,10 @@ struct si_pipe_shader_selector {
 
 struct si_shader {
        unsigned                ninput;
-       struct si_shader_io     input[32];
+       struct si_shader_io     input[40];
 
        unsigned                noutput;
-       struct si_shader_io     output[32];
+       struct si_shader_io     output[40];
 
        unsigned                ninterp;
        bool                    uses_kill;