[Mesa-dev] [PATCH] glsl: bail out early in _mesa_ShaderSource if no shaderobj

Iago Toral itoral at igalia.com
Tue Sep 22 05:27:33 PDT 2015


On Tue, 2015-09-22 at 14:34 +0300, Tapani Pälli wrote:
> Patch fixes a crash in conformance test that tries out different
> invalid arguments for glShaderSource and glGetShaderSource:
> 
>    ES2-CTS.gtf.GL.glGetShaderSource.getshadersource_programhandle
> 
> This is a regression from commit:
>    04e201d0c02cd30ace5c6fe80e9f021ebb733682
> 
> Additions in v2 also fix following failing deqp test:
>    dEQP-GLES[2|3].functional.negative_api.shader.shader_source

Nice! I wasn't expecting that :)

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

> v2: cleanup function, do check earlier (Iago Toral)
> 
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
>  src/mesa/main/shaderapi.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index f31980b..edc23bc 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -931,13 +931,9 @@ get_shader_source(struct gl_context *ctx, GLuint shader, GLsizei maxLength,
>   * glShaderSource[ARB].
>   */
>  static void
> -shader_source(struct gl_context *ctx, GLuint shader, const GLchar *source)
> +shader_source(struct gl_shader *sh, const GLchar *source)
>  {
> -   struct gl_shader *sh;
> -
> -   sh = _mesa_lookup_shader_err(ctx, shader, "glShaderSource");
> -   if (!sh)
> -      return;
> +   assert(sh);
>  
>     /* free old shader source string and install new one */
>     free((void *)sh->Source);
> @@ -1639,13 +1635,17 @@ _mesa_ShaderSource(GLhandleARB shaderObj, GLsizei count,
>     GLint *offsets;
>     GLsizei i, totalLength;
>     GLcharARB *source;
> +   struct gl_shader *sh;
>  
>  #if defined(HAVE_SHA1)
>     GLcharARB *replacement;
> -   struct gl_shader *sh;
>  #endif /* HAVE_SHA1 */
>  
> -   if (!shaderObj || string == NULL) {
> +   sh = _mesa_lookup_shader_err(ctx, shaderObj, "glShaderSourceARB");
> +   if (!sh)
> +      return;
> +
> +   if (string == NULL) {
>        _mesa_error(ctx, GL_INVALID_VALUE, "glShaderSourceARB");
>        return;
>     }
> @@ -1697,8 +1697,6 @@ _mesa_ShaderSource(GLhandleARB shaderObj, GLsizei count,
>     source[totalLength - 2] = '\0';
>  
>  #if defined(HAVE_SHA1)
> -   sh = _mesa_lookup_shader(ctx, shaderObj);
> -
>     /* Dump original shader source to MESA_SHADER_DUMP_PATH and replace
>      * if corresponding entry found from MESA_SHADER_READ_PATH.
>      */
> @@ -1711,7 +1709,7 @@ _mesa_ShaderSource(GLhandleARB shaderObj, GLsizei count,
>     }
>  #endif /* HAVE_SHA1 */
>  
> -   shader_source(ctx, shaderObj, source);
> +   shader_source(sh, source);
>  
>     free(offsets);
>  }




More information about the mesa-dev mailing list