[Mesa-dev] [PATCH 1/3] glsl: Bail on parsing if the #version directive is bogus.

Matt Turner mattst88 at gmail.com
Fri Jun 7 22:51:30 PDT 2013


On Fri, Jun 7, 2013 at 10:42 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> If we didn't successfully parse the #version line, there's no point in
> continuing with parsing and compiling: it's already failed.
>
> Furthermore, it can actually be harmful: right after handling #version,
> we call _mesa_glsl_initialize_types(), which checks state->es_shader and
> language_version.  If it isn't valid, it hits an assertion failure.
>
> Fixes Piglit's "invalid-version-es."  When processing "#version 110 es",
> our code set state->es_shader and state->language_version = 110.  It
> then properly determined that this was invalid and flagged an error.
> Since we continued anyway, we hit the assertion mentioned above.
>
> NOTE: This is a candidate for the 9.1 branch.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/glsl/glsl_parser.yy | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 6e92c26..56367f8 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
> @@ -267,10 +267,16 @@ version_statement:
>         | VERSION_TOK INTCONSTANT EOL
>         {
>             state->process_version_directive(&@2, $2, NULL);
> +          if (state->error) {
> +             YYERROR;
> +          }
>         }
>          | VERSION_TOK INTCONSTANT any_identifier EOL
>          {
>             state->process_version_directive(&@2, $2, $3);
> +          if (state->error) {
> +             YYERROR;
> +          }
>          }
>         ;
>
> --
> 1.8.3

Series is
Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list