[PATCH] d3dcompiler: Iterate through the instruction list in reverse in free_instr_list() (Valgrind).
To avoid heap corruption when unlinking the instruction from the "uses" list. Signed-off-by: Zebediah Figura <z.figura12(a)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); } -- 2.27.0
On Wed, Aug 5, 2020 at 6:31 PM Zebediah Figura <z.figura12(a)gmail.com> wrote:
To avoid heap corruption when unlinking the instruction from the "uses" list.
Signed-off-by: Zebediah Figura <z.figura12(a)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.
On 8/10/20 10:42 AM, Matteo Bruni wrote:
On Wed, Aug 5, 2020 at 6:31 PM Zebediah Figura <z.figura12(a)gmail.com> wrote:
To avoid heap corruption when unlinking the instruction from the "uses" list.
Signed-off-by: Zebediah Figura <z.figura12(a)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.
participants (3)
-
Matteo Bruni -
Zebediah Figura -
Zebediah Figura