[Mesa-dev] [PATCH 5/5] mesa: Add an assertion to _mesa_program_index_to_target().

Paul Berry stereotype441 at gmail.com
Tue Dec 17 10:23:38 PST 2013


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.
---
 src/mesa/program/program.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 135271c..baff473 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -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];
 }
 
-- 
1.8.4.2



More information about the mesa-dev mailing list