[PATCH] d3dcompiler: Iterate through the instruction list in reverse in free_instr_list() (Valgrind).

Zebediah Figura zfigura at codeweavers.com
Mon Aug 10 11:09:38 CDT 2020


On 8/10/20 10:42 AM, Matteo Bruni wrote:
> On Wed, Aug 5, 2020 at 6:31 PM Zebediah Figura <z.figura12 at gmail.com> wrote:
>>
>> To avoid heap corruption when unlinking the instruction from the "uses" list.
>>
>> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
>> ---
>> Alternatively, we could make unlinking into a separate operation.
>>
>>  dlls/d3dcompiler_43/utils.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
>> index e8bdbea7e13..ac5722e11aa 100644
>> --- a/dlls/d3dcompiler_43/utils.c
>> +++ b/dlls/d3dcompiler_43/utils.c
>> @@ -1937,7 +1937,7 @@ void free_instr_list(struct list *list)
>>
>>      if (!list)
>>          return;
>> -    LIST_FOR_EACH_ENTRY_SAFE(node, next_node, list, struct hlsl_ir_node, entry)
>> +    LIST_FOR_EACH_ENTRY_SAFE_REV(node, next_node, list, struct hlsl_ir_node, entry)
>>          free_instr(node);
>>      d3dcompiler_free(list);
>>  }
> 
> Freeing in reverse should be fine but I think it deserves a comment in
> the code, this is definitely not obvious.
> 

Agreed, good point.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200810/c774001a/attachment.sig>


More information about the wine-devel mailing list