[Mesa-dev] [PATCH] glsl: Fix memory leak in glsl_lexer.ll

Matt Turner mattst88 at gmail.com
Wed Sep 3 11:15:07 PDT 2014


On Wed, Sep 3, 2014 at 7:03 AM, Juha-Pekka Heikkila
<juhapekka.heikkila at gmail.com> wrote:
> Running fast clear glClear with SNB caused Valgrind to
> complain about this.
>
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
>  src/glsl/glsl_lexer.ll | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
> index b7c4aad..a9274a3 100644
> --- a/src/glsl/glsl_lexer.ll
> +++ b/src/glsl/glsl_lexer.ll
> @@ -232,7 +232,8 @@ HASH                ^{SPC}#{SPC}
>  <PP>[ \t\r]*                   { }
>  <PP>:                          return COLON;
>  <PP>[_a-zA-Z][_a-zA-Z0-9]*     {
> -                                  yylval->identifier = strdup(yytext);
> +                                  void *ctx = yyextra;
> +                                  yylval->identifier = ralloc_strdup(ctx, yytext);
>                                    return IDENTIFIER;
>                                 }
>  <PP>[1-9][0-9]*                        {

There's another use of strdup() in this file. I assume it needs the
same treatment.


More information about the mesa-dev mailing list