From ff7446ba0c91410870a46558ef2d02b1d6b1b8ed Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Thu, 16 Feb 2023 01:43:20 +0100 Subject: [PATCH] mesa/program: fix memory leak triggered by arb alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function _mesa_symbol_table_add_symbol() copies the string with strdup(), the original string should be freed. For instance, with "piglit/fp-fragment-position -auto -fbo": Direct leak of 7 byte(s) in 1 object(s) allocated from: #0 0xffff99c59050 in __interceptor_strdup (/usr/lib64/libasan.so.6+0x59050) #1 0xffff8f53d24c in handle_ident ../src/mesa/program/program_lexer.l:129 #2 0xffff8f53d24c in _mesa_program_lexer_lex ../src/mesa/program/program_lexer.l:312 #3 0xffff8f529d10 in yylex ../src/mesa/program/program_parse.y:289 #4 0xffff8f529d10 in yyparse src/mesa/program/program_parse.tab.c:2140 #5 0xffff8f5341a4 in _mesa_parse_arb_program ../src/mesa/program/program_parse.y:2589 #6 0xffff8f51e96c in _mesa_parse_arb_fragment_program ../src/mesa/program/arbprogparse.c:82 #7 0xffff8f4d867c in set_program_string ../src/mesa/main/arbprogram.c:402 Signed-off-by: Patrick Lerda Reviewed-by: Marek Olšák Part-of: --- src/mesa/program/program_parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 862ca88cf72e..ed552fc18272 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -2068,6 +2068,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER YYERROR; } else { _mesa_symbol_table_add_symbol(state->st, $2, target); + free($2); } (void)yynerrs; }