mesa/program: fix memory leak triggered by multiple targets used on one texture image unit

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 <patrick9876@free.fr>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21728>
This commit is contained in:
Patrick Lerda
2023-02-28 18:38:56 +01:00
committed by Marge Bot
parent 444250a5e7
commit a692fe418e
+2
View File
@@ -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;
}