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

Matteo Bruni matteo.mystral at gmail.com
Mon Aug 10 10:42:11 CDT 2020


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.



More information about the wine-devel mailing list