diff options
author | Timothy Arceri <tarceri@itsqueeze.com> | 2021-04-27 14:01:08 +1000 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-04-30 01:18:47 +0000 |
commit | 60fa555e615a49efd92c7396618907bc9f83eaa2 (patch) | |
tree | a08336a29807f7813d2e8ae22abbd2b37f519405 | |
parent | 58f843a193b99994479da48f0d65360efe8a4a8d (diff) |
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@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10477>
-rw-r--r-- | src/mesa/main/shaderapi.c | 6 |
1 files changed, 5 insertions, 1 deletions
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. |