From 60fa555e615a49efd92c7396618907bc9f83eaa2 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Tue, 27 Apr 2021 14:01:08 +1000 Subject: [PATCH] mesa: fix glShaderSource() error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Section 7.1 (SHADER OBJECTS) of the OpenGL 4.6 spec says: "An INVALID_VALUE error is generated if count is negative." However a count of 0 is not an error. Previously it would cause a GL_OUT_OF_MEMORY error. Reviewed-by: Tapani Pälli Part-of: --- src/mesa/main/shaderapi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 4204a930743..bf372dceecd 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -2050,7 +2050,7 @@ shader_source(struct gl_context *ctx, GLuint shaderObj, GLsizei count, if (!sh) return; - if (string == NULL) { + if (string == NULL || count < 0) { _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB"); return; } @@ -2058,6 +2058,10 @@ shader_source(struct gl_context *ctx, GLuint shaderObj, GLsizei count, sh = _mesa_lookup_shader(ctx, shaderObj); } + /* Return silently the spec doesn't define this as an error */ + if (count == 0) + return; + /* * This array holds offsets of where the appropriate string ends, thus the * last element will be set to the total length of the source code.