mesa: Add an assertion to _mesa_program_index_to_target().
authorPaul Berry <stereotype441@gmail.com>
Tue, 17 Dec 2013 18:11:27 +0000 (10:11 -0800)
committerPaul Berry <stereotype441@gmail.com>
Mon, 30 Dec 2013 19:21:33 +0000 (11:21 -0800)
Only a Mesa bug could cause this function to be called with an
out-of-range index, so raise an assertion if that ever happens.

Reviewed-by: Brian Paul <brianp@vmware.com>
src/mesa/program/program.h

index 135271caf9a3206f045f9f43a9548bd9faf61468..baff473764d9f04594874d8c88ec8485531fc2d7 100644 (file)
@@ -216,9 +216,10 @@ _mesa_program_index_to_target(GLuint i)
       GL_FRAGMENT_PROGRAM_ARB
    };
    STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES);
-   if(i >= MESA_SHADER_TYPES)
+   if(i >= MESA_SHADER_TYPES) {
+      assert(!"Unexpected program index");
       return 0;
-   else
+   else
       return enums[i];
 }