summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-04-28 10:57:45 -0600
committerBrian Paul <brianp@vmware.com>2009-06-17 11:30:01 -0600
commitce58dfd4a98dac171ee49068dee543abf64f615e (patch)
tree46eb33c1b3edd29d564a7e259dc7ec09a7277b25
parent5dd7aba443935048eb65b5e29b4e8c16cbd1fe93 (diff)
mesa: Fix buffer overflow when parsing generic vertex attributes.
(cherry picked from master, commit fa92756400ccfbb3f0201df634feb45ab4f98352)
-rw-r--r--src/mesa/shader/arbprogparse.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 331200e50e7..e6d0955774f 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1512,10 +1512,16 @@ generic_attrib_check(struct var_cache *vc_head)
curr = vc_head;
while (curr) {
if (curr->type == vt_attrib) {
- if (curr->attrib_is_generic)
- genericAttrib[ curr->attrib_binding ] = GL_TRUE;
- else
+ if (curr->attrib_is_generic) {
+ GLuint attr = (curr->attrib_binding == 0)
+ ? 0 : (curr->attrib_binding - VERT_ATTRIB_GENERIC0);
+ assert(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+ genericAttrib[attr] = GL_TRUE;
+ }
+ else {
+ assert(curr->attrib_binding < MAX_VERTEX_PROGRAM_ATTRIBS);
explicitAttrib[ curr->attrib_binding ] = GL_TRUE;
+ }
}
curr = curr->next;