mesa: Raise INVALID_VALUE from glCreateShaderProgramv if count < 0
authorMarta Lofstedt <marta.lofstedt@intel.com>
Thu, 13 Aug 2015 12:38:14 +0000 (14:38 +0200)
committerTapani Pälli <tapani.palli@intel.com>
Mon, 17 Aug 2015 07:29:07 +0000 (10:29 +0300)
According to OpenGL version 4.5 and OpenGL ES 3.1 standards, section 7.3:
GL_INVALID_VALUE should be generated, if count is less than 0.

V2: Changed title, eased Open GL ES 3.1 restriction and added comments.

Signed-off-by: Marta Lofstedt <marta.lofstedt@intel.com>
Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au>
src/mesa/main/shaderapi.c

index f9a7d130f9ce5ab4c9b80e259b3e47bcf5434e95..16222747905faab930ec1f498f28fdf6b530bfa5 100644 (file)
@@ -2003,6 +2003,15 @@ _mesa_create_shader_program(struct gl_context* ctx, GLboolean separate,
    const GLuint shader = create_shader(ctx, type);
    GLuint program = 0;
 
+   /*
+    * According to OpenGL 4.5 and OpenGL ES 3.1 standards, section 7.3:
+    * GL_INVALID_VALUE should be generated if count < 0
+    */
+   if (count < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glCreateShaderProgram (count < 0)");
+      return program;
+   }
+
    if (shader) {
       _mesa_ShaderSource(shader, count, strings, NULL);