On 09/11/2017 01:21 PM, Thomas Helland wrote:
> @@ -621,12 +636,17 @@ u64vec4         KEYWORD_WITH_ALT(0, 0, 0, 0, 
> yyextra->ARB_gpu_shader_int64_enable, U64V
>  [_a-zA-Z][_a-zA-Z0-9]*       {
>                           struct _mesa_glsl_parse_state *state = yyextra;
>                           void *ctx = state->linalloc;
> -                         if (state->es_shader && strlen(yytext) > 1024) {
> +                         if (state->es_shader && yyleng + 1 > 1024) {

Also... I don't think this is right.  Shouldn't this just be 'yylen > 1024'?

>                              _mesa_glsl_error(yylloc, state,
>                                               "Identifier `%s' exceeds 1024 
> characters",
>                                               yytext);
>                           } else {
> -                           yylval->identifier = linear_strdup(ctx, yytext);
> +                           /* We're not doing linear_strdup here, to avoid 
> an implicit call
> +                            * on strlen() for the length of the string, as 
> this is already
> +                            * found by flex and stored in yyleng
> +                            */
> +                           yylval->identifier = (char *) 
> linear_alloc_child(ctx, yyleng + 1);
> +                           memcpy(yylval->identifier, yytext, yyleng + 1);
>                           }
>                           return classify_identifier(state, yytext);
>                       }
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to