mesa/program: fix memory leak triggered by invalid extended swizzle selector
authorPatrick Lerda <patrick9876@free.fr>
Tue, 28 Feb 2023 16:49:14 +0000 (17:49 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 7 Mar 2023 23:11:29 +0000 (23:11 +0000)
For instance, with "piglit/bin/asmparsertest ARBfp1.0 tests/asmparsertest/shaders/ARBfp1.0/swz-04.txt":
Direct leak of 18 byte(s) in 2 object(s) allocated from:
    #0 0x7f97e99050 in __interceptor_strdup (/usr/lib64/libasan.so.6+0x59050)
    #1 0x7f8d4160ac in handle_ident ../src/mesa/program/program_lexer.l:129
    #2 0x7f8d4160ac in _mesa_program_lexer_lex ../src/mesa/program/program_lexer.l:312
    #3 0x7f8d402b50 in yylex ../src/mesa/program/program_parse.y:289
    #4 0x7f8d402b50 in yyparse src/mesa/program/program_parse.tab.c:2140
    #5 0x7f8d40d01c in _mesa_parse_arb_program ../src/mesa/program/program_parse.y:2590
    #6 0x7f8d3f77ac in _mesa_parse_arb_fragment_program ../src/mesa/program/arbprogparse.c:82
    #7 0x7f8d3ad468 in set_program_string ../src/mesa/main/arbprogram.c:402

Signed-off-by: Patrick Lerda <patrick9876@free.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21728>

src/mesa/program/program_parse.y

index ba4757f..0f5fdcb 100644 (file)
@@ -684,6 +684,7 @@ extSwizSel: INTEGER
 
       if (strlen($1) > 1) {
          yyerror(& @1, state, "invalid extended swizzle selector");
+         free($1);
          YYERROR;
       }