summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2002-08-17 00:26:29 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2002-08-17 00:26:29 +0000
commit9f7011b88bd8dfeb0ddeed65c4c1ef39ad44798a (patch)
treeb5c677f87466ad8f7af06d22b94d3141bb55ff74 /src/mesa/main
parentaf3265fabd7f385aa8aaf207416674799869dc95 (diff)
added error checking for glCallLists() type parameter
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/dlist.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 07687e4dab..deb4995ff1 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.92 2002/06/30 15:47:00 brianp Exp $ */
+/* $Id: dlist.c,v 1.93 2002/08/17 00:26:29 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -520,7 +520,7 @@ void _mesa_init_lists( void )
InstSize[OPCODE_BLEND_FUNC] = 3;
InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
InstSize[OPCODE_CALL_LIST] = 2;
- InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
+ InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
InstSize[OPCODE_CLEAR] = 2;
InstSize[OPCODE_CLEAR_ACCUM] = 5;
InstSize[OPCODE_CLEAR_COLOR] = 5;
@@ -898,14 +898,34 @@ void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
+ GLboolean typeErrorFlag;
+
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
FLUSH_CURRENT(ctx, 0);
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ typeErrorFlag = GL_FALSE;
+ break;
+ default:
+ typeErrorFlag = GL_TRUE;
+ }
+
for (i=0;i<n;i++) {
GLuint list = translate_id( i, type, lists );
- Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
+ Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
if (n) {
n[1].ui = list;
+ n[2].b = typeErrorFlag;
}
}
if (ctx->ExecuteFlag) {
@@ -4201,7 +4221,11 @@ execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_CALL_LIST_OFFSET:
/* Generated by glCallLists() so we must add ListBase */
- if (ctx->CallDepth<MAX_LIST_NESTING) {
+ if (n[2].b) {
+ /* user specified a bad datatype at compile time */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+ }
+ else if (ctx->CallDepth < MAX_LIST_NESTING) {
execute_list( ctx, ctx->List.ListBase + n[1].ui );
}
break;
@@ -5059,6 +5083,24 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "_mesa_CallLists %d\n", n);
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+ return;
+ }
+
/* Save the CompileFlag status, turn it off, execute display list,
* and restore the CompileFlag.
*/