Mesa (master): mesa: fix glShaderSource() error handling

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 30 01:49:46 UTC 2021


Module: Mesa
Branch: master
Commit: 60fa555e615a49efd92c7396618907bc9f83eaa2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=60fa555e615a49efd92c7396618907bc9f83eaa2

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Tue Apr 27 14:01:08 2021 +1000

mesa: fix glShaderSource() error handling

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 <tapani.palli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10477>

---

 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.



More information about the mesa-commit mailing list