diff options
author | Brian Paul <brianp@vmware.com> | 2010-01-26 12:47:51 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2010-01-26 12:47:54 -0700 |
commit | 645e297a0019eb2f7513bd801ffdaac03187f29f (patch) | |
tree | 7a4d78a57c056e79062ccab42887a81829e6c19b /src/mesa/vbo | |
parent | af1e9403e732651fe2cedde230ac7010f2f1a649 (diff) |
vbo: clamp DrawElements start/end to max possible values
Some apps are sloppy with their start/end values. Clamp them to
max possible values to prevent problems later.
Diffstat (limited to 'src/mesa/vbo')
-rw-r--r-- | src/mesa/vbo/vbo_exec_array.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 2c82f7c9c5..f455382592 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -688,6 +688,16 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, * or we can read/write out of memory in several different places! */ + /* Catch/fix some potential user errors */ + if (type == GL_UNSIGNED_BYTE) { + start = MIN2(start, 0xff); + end = MIN2(end, 0xff); + } + else if (type == GL_UNSIGNED_SHORT) { + start = MIN2(start, 0xffff); + end = MIN2(end, 0xffff); + } + if (end >= ctx->Array.ArrayObj->_MaxElement) { /* the max element is out of bounds of one or more enabled arrays */ warnCount++; |