Skip to content

Commit

Permalink
mesa/program: fix memory leak triggered by arb alias
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21728>
  • Loading branch information
Patrick Lerda authored and Marge Bot committed Mar 7, 2023
1 parent a692fe4 commit ff7446b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/mesa/program/program_parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ff7446b

Please sign in to comment.