diff options
author | Zack Rusin <[email protected]> | 2014-03-03 23:09:58 -0500 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2014-03-04 15:56:04 -0500 |
commit | 1dd84357ec8d6894ec6bbd7040a8e8328015cd16 (patch) | |
tree | c60fe0c84816a98afa14c095267fac3b79bcc39c /src/gallium/auxiliary/translate/translate_generic.c | |
parent | 08f174daa41b89c41a87c350f407307e2ba258eb (diff) |
translate: fix buffer overflows
Because in draw we always inject position at slot 0 whenever
fragment shader would take the maximum number of inputs (32) it
meant that we had PIPE_MAX_ATTRIBS + 1 slots to translate, which
meant that we were crashing with fragment shaders that took
the maximum number of attributes as inputs. The actual max number
of attributes we need to translate thus is PIPE_MAX_ATTRIBS + 1.
Signed-off-by: Zack Rusin <[email protected]>
Reviewed-by: José Fonseca <[email protected]>
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Matthew McClure <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/translate/translate_generic.c')
-rw-r--r-- | src/gallium/auxiliary/translate/translate_generic.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index 5ffce32ba70..26b87c5af1c 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -73,7 +73,7 @@ struct translate_generic { */ int copy_size; - } attrib[PIPE_MAX_ATTRIBS]; + } attrib[TRANSLATE_MAX_ATTRIBS]; unsigned nr_attrib; }; @@ -799,6 +799,8 @@ struct translate *translate_generic_create( const struct translate_key *key ) if (tg == NULL) return NULL; + assert(key->nr_elements <= TRANSLATE_MAX_ATTRIBS); + tg->translate.key = *key; tg->translate.release = generic_release; tg->translate.set_buffer = generic_set_buffer; |