Module: Mesa
Branch: 9.1
Commit: 238dc959d28a3dfaba60574e86bdc649f8ddf940
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=238dc959d28a3dfaba60574e86bdc649f8ddf940

Author: Marek Olšák <[email protected]>
Date:   Tue May 14 19:37:17 2013 +0200

radeonsi: increase array size for shader inputs and outputs

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 <[email protected]>
(cherry picked from commit 2eac0aa1d8d6fbdbbee43e44b24cff7f71733764)

---

 src/gallium/drivers/radeonsi/radeonsi_shader.c |    3 +++
 src/gallium/drivers/radeonsi/radeonsi_shader.h |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 7922928..ac654e6 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -35,6 +35,7 @@
 #include "gallivm/lp_bld_tgsi.h"
 #include "radeon_llvm.h"
 #include "radeon_llvm_emit.h"
+#include "util/u_memory.h"
 #include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_scan.h"
@@ -626,6 +627,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;
@@ -634,6 +636,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;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h 
b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index f54f67c..7960fc9 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -66,10 +66,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;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to