From a692fe418ed0b2c6534d170d3e8adbfeab466e6b Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Tue, 28 Feb 2023 18:38:56 +0100 Subject: [PATCH] mesa/program: fix memory leak triggered by multiple targets used on one texture image unit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For instance, with "piglit-2000/bin/asmparsertest ARBfp1.0 tests/asmparsertest/shaders/ARBfp1.0/shadow-02.txt": Direct leak of 192 byte(s) in 2 object(s) allocated from: #0 0x7f6e8378f987 in calloc (/usr/lib64/libasan.so.6+0xb1987) #1 0x7f6e7769d620 in asm_instruction_copy_ctor ../src/mesa/program/program_parse.y:2146 #2 0x7f6e7769d620 in yyparse ../src/mesa/program/program_parse.y:439 #3 0x7f6e776a6725 in _mesa_parse_arb_program ../src/mesa/program/program_parse.y:2590 #4 0x7f6e77687f69 in _mesa_parse_arb_fragment_program ../src/mesa/program/arbprogparse.c:82 #5 0x7f6e77630765 in set_program_string ../src/mesa/main/arbprogram.c:402 #6 0x7f6e76ec3e8a in _mesa_unmarshal_ProgramStringARB src/mapi/glapi/gen/marshal_generated2.c:4152 #7 0x7f6e76a0e585 in glthread_unmarshal_batch ../src/mesa/main/glthread.c:122 #8 0x7f6e76a1031d in _mesa_glthread_finish ../src/mesa/main/glthread.c:383 #9 0x7f6e76a1031d in _mesa_glthread_finish ../src/mesa/main/glthread.c:348 #10 0x7f6e76e6a062 in _mesa_marshal_GetError src/mapi/glapi/gen/marshal_generated1.c:1809 Signed-off-by: Patrick Lerda Reviewed-by: Marek Olšák Part-of: --- src/mesa/program/program_parse.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 0f5fdcb4f84..862ca88cf72 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -468,6 +468,7 @@ SAMPLE_instruction: SAMPLE_OP maskedDstReg ',' swizzleSrcReg ',' texImageUnit ', != shadow_tex))) { yyerror(& @8, state, "multiple targets used on one texture image unit"); + free($$); YYERROR; } @@ -519,6 +520,7 @@ TXD_instruction: TXD_OP maskedDstReg ',' swizzleSrcReg ',' swizzleSrcReg ',' swi != shadow_tex))) { yyerror(& @12, state, "multiple targets used on one texture image unit"); + free($$); YYERROR; }